SOLVED

How to trigger a flow based on change in title column of documentset?

%3CLINGO-SUB%20id%3D%22lingo-sub-3220251%22%20slang%3D%22en-US%22%3EHow%20to%20trigger%20a%20flow%20based%20on%20change%20in%20title%20column%20of%20documentset%3F%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-3220251%22%20slang%3D%22en-US%22%3E%3CP%3EI%20am%20trying%20to%20trigger%20a%20flow%20only%20when%20the%20columns%20(metadata)%20of%20a%20documentset%20is%20changing.%3C%2FP%3E%3CP%3EMy%20documentset%20consists%20of%20several%20columns%20and%20standard%20folders.%3CBR%20%2F%3EFor%20business%20reasons%20I%20want%20to%20trigger%20a%20Power%20Automate%20flow%20only%20when%20a%20certain%20column%20is%20changed.%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EThe%20Tigger%20condition%20I%20use%20for%20%E2%80%98when%20an%20item%20or%20file%20is%20modified%E2%80%99%20is%3A%3CBR%20%2F%3E%3CBR%20%2F%3E%40equals(triggerBody()%3F%5B'%7BContentType%7D'%5D%3F%5B'Id'%5D%2C%20'0x0120D52000C5A1E6112625E241BF1968469A689EB7001463D6ACDB134C4CB9D00A39A6072585')%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EThe%20Id%20is%20from%20the%20Document%20set%20content%20type.%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EThe%20problem%20is%20that%20the%20flow%20is%20also%20triggered%20when%20a%20document%20or%20folder%20within%20the%20documentset%20has%20changed.%20I%20am%20guessing%20that%20this%20is%20due%20to%20the%20fact%2C%20that%20changes%20within%20the%20documentset%20also%20count%20as%20a%20change%20of%20the%20documentset%20itself.%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EWhen%20looking%20at%20the%20output%3B%20I%20see%20the%20Id%20of%20the%20documentset%20is%20the%20item%20that%20is%20changed%3A%3C%2FP%3E%3CP%3E%3CSPAN%20class%3D%22lia-inline-image-display-wrapper%20lia-image-align-center%22%20image-alt%3D%22flow%20with%20contentsype.jpg%22%20style%3D%22width%3A%20400px%3B%22%3E%3CIMG%20src%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fimage%2Fserverpage%2Fimage-id%2F351684i379045247A8ADEBE%2Fimage-size%2Fmedium%3Fv%3Dv2%26amp%3Bpx%3D400%22%20role%3D%22button%22%20title%3D%22flow%20with%20contentsype.jpg%22%20alt%3D%22flow%20with%20contentsype.jpg%22%20%2F%3E%3C%2FSPAN%3E%3C%2FP%3E%3CP%3E%3CSTRONG%3E%3CSPAN%3EMy%20question%3A%3C%2FSPAN%3E%3C%2FSTRONG%3E%3C%2FP%3E%3CP%3EIs%20it%20possible%20to%20start%20a%20trigger%20for%20a%20flow%20only%20when%20a%20certain%20metadata%20field%20is%20changing%3F%3C%2FP%3E%3CP%3EIn%20my%20case%20this%20is%20the%20%E2%80%98title%20field%E2%80%99.%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-LABS%20id%3D%22lingo-labs-3220251%22%20slang%3D%22en-US%22%3E%3CLINGO-LABEL%3EMicrosoft%20Flow%3C%2FLINGO-LABEL%3E%3CLINGO-LABEL%3ESharePoint%3C%2FLINGO-LABEL%3E%3C%2FLINGO-LABS%3E%3CLINGO-SUB%20id%3D%22lingo-sub-3239687%22%20slang%3D%22en-US%22%3ERe%3A%20How%20to%20trigger%20a%20flow%20based%20on%20change%20in%20title%20column%20of%20documentset%3F%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-3239687%22%20slang%3D%22en-US%22%3E%3CP%3E%3CA%20href%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fuser%2Fviewprofilepage%2Fuser-id%2F1319572%22%20target%3D%22_blank%22%3E%40RJDBakker%3C%2FA%3E%26nbsp%3B%3CBR%20%2F%3EYou%20could%20accomplish%20this%20with%20an%20additional%20action%20and%20a%20condition%20after%20your%20trigger.%3CBR%20%2F%3ELook%20for%20the%20SharePoint%20connector%20action%20'Get%20changes%20for%20an%20item%20or%20a%20file%20(properties%20only)'.%3CBR%20%2F%3EThis%20way%20you%20get%20the%20columns%20which%20have%20been%20changed%20by%20comparing%20them%20to%20the%20previous%20version%20('Since'%20expression%20below).%3CBR%20%2F%3E%3CBR%20%2F%3EDynamically%20link%20the%20site%20and%20the%20library%20from%20the%20triggers%20properties%3A%3C%2FP%3E%3CUL%3E%3CLI%3E%3CSTRONG%3Esite%3C%2FSTRONG%3E%3A%20trigger()%3F%5B'inputs'%5D%3F%5B'parameters'%5D%3F%5B'dataset'%5D%3C%2FLI%3E%3CLI%3E%3CSTRONG%3Elibrary%3C%2FSTRONG%3E%3A%20trigger()%3F%5B'inputs'%5D%3F%5B'parameters'%5D%3F%5B'table'%5D%3C%2FLI%3E%3CLI%3E%3CSTRONG%3EID%3C%2FSTRONG%3E%3A%26nbsp%3BtriggerOutputs()%3F%5B'body%2FID'%5D%3C%2FLI%3E%3CLI%3E%3CDIV%3E%3CDIV%3E%3CSPAN%3E%3CSTRONG%3ESince%3C%2FSTRONG%3E%20%3A%20sub(int(triggerOutputs()%3F%5B%3C%2FSPAN%3E%3CSPAN%3E'body%2F%7BVersionNumber%7D'%3C%2FSPAN%3E%3CSPAN%3E%5D)%2C1)%3C%2FSPAN%3E%3C%2FDIV%3E%3CDIV%3E%3CSPAN%3E%3CBR%20%2F%3EAfterwards%20use%20a%20condition%20to%20check%20if%20the%20title%20column%20returns%20true%20for%20any%20column%20change%3A%3CBR%20%2F%3E%3CBR%20%2F%3Eoutputs('Get_changes_for_an_item_or_a_file_(properties_only)')%3F%5B'body%2FColumnHasChanged%2FTitle'%5D%3CBR%20%2F%3E%3CBR%20%2F%3EThis%20would%20not%20avoid%20the%20additional%20Flow%20run%2C%20but%20at%20least%20any%20action%20could%20depend%20on%20a%20certain%20column%20change%20only.%3CBR%20%2F%3E%3CBR%20%2F%3E%3C%2FSPAN%3E%3C%2FDIV%3E%3C%2FDIV%3E%3C%2FLI%3E%3C%2FUL%3E%3C%2FLINGO-BODY%3E
New Contributor

I am trying to trigger a flow only when the columns (metadata) of a documentset is changing.

My documentset consists of several columns and standard folders.
For business reasons I want to trigger a Power Automate flow only when a certain column is changed.

 

The Tigger condition I use for ‘when an item or file is modified’ is:

@equals(triggerBody()?['{ContentType}']?['Id'], '0x0120D52000C5A1E6112625E241BF1968469A689EB7001463D6ACDB134C4CB9D00A39A6072585')

 

The Id is from the Document set content type.

 

The problem is that the flow is also triggered when a document or folder within the documentset has changed. I am guessing that this is due to the fact, that changes within the documentset also count as a change of the documentset itself.

 

When looking at the output; I see the Id of the documentset is the item that is changed:

flow with contentsype.jpg

My question:

Is it possible to start a trigger for a flow only when a certain metadata field is changing?

In my case this is the ‘title field’.

 

4 Replies

@RJDBakker 
You could accomplish this with an additional action and a condition after your trigger.
Look for the SharePoint connector action 'Get changes for an item or a file (properties only)'.
This way you get the columns which have been changed by comparing them to the previous version ('Since' expression below).

Dynamically link the site and the library from the triggers properties:

  • site: trigger()?['inputs']?['parameters']?['dataset']
  • library: trigger()?['inputs']?['parameters']?['table']
  • ID: triggerOutputs()?['body/ID']
  • Since : sub(int(triggerOutputs()?['body/{VersionNumber}']),1)

    Afterwards use a condition to check if the title column returns true for any column change:

    outputs('Get_changes_for_an_item_or_a_file_(properties_only)')?['body/ColumnHasChanged/Title']

    This would not avoid the additional Flow run, but at least any action could depend on a certain column change only.

@Micca0815 

 

Thank you for your reply

Your suggestion is much useful.

But I am still looking for a way to not trigger the flow at all.
This is because of the fact that it will otherwise trigger 1000’s of time every week.

Documents are changed and uploaded constantly. The metadata field will probably change a very few times during the lifespan of the document set.

 

At this point I think it is not possible to prevent the flow from starting based on the ‘only run when the title changes’ trigger and have to look for a more user unfriendly alternative.

 

The root cause of my problem is that the ‘filename’ field cannot be changed natively from a PowerApps form. During the initializing of the Document set I trigger a flow that copies the filename field to the title field. After that, the user has the possibility to change the title.

 

My idea was, that the title field then again would be copied to the filename field automatically.

best response confirmed by RJDBakker (New Contributor)
Solution

@RJDBakker 

In this case, have you tried to add the additional, required condition within the triggers` settings?

@and(
     NOT(equals(
            triggerBody()?['Title'],
            triggerBody()?['{Name}']
               )
       )
     ,
     equals(
        triggerBody()?['{ContentType}']?['Id'],
        '0x0123456789abcdefghijk9876543210kjihgfedcba'
          )
     )

 

@Micca0815 

 

I really appreciate your response.

The additional trigger you suggested seems to do the trick.

I replaced the Content Type ID from your example of course.

 

Although I still find it a bit of a cumbersome way changing the filename trough PowerApps and Power Automate, your solution works! Thank you for your time.

 

I thought it would be useful to post the complete working flow to understand the context:

 

I have a flow that is generating a document set. I use a customized PowerApps form to fill in the metadata for the document set. When using a custom PowerApps form, it is not possible to change the filename field. (at the time of writing) Instead I use the ‘title’ field in the form that is available for users to edit.

 

complete.jpg

 

A Power Automate flow would trigger when this field does change and writes the change also back into the ‘filename’ field. But of course you want to prevent that the flow would start every time a file within the document set would change.

 

The triggers prevent this from happening:

@equals(triggerBody()?['{ContentType}']?['Id'], '0x0120D52000C5A1E6112625E241BF1968469A689EB7001463D6ACDB134C4CB9D00A39A6072585')

@and(NOT(equals(triggerBody()?['Title'],triggerBody()?['{Name}'] ) ),equals(triggerBody()?['{ContentType}']?['Id'],'0x0120D52000C5A1E6112625E241BF1968469A689EB7001463D6ACDB134C4CB9D00A39A6072585'))

 

These are set in the 'settings' from the trigger of the flow.

 

error2.jpg