Power Automate flow triggerede by "When a row is added, modified or deleted" not triggered - dynamics-crm

I'm new to Microsoft CRM and Power Automate. I'm trying to implement the Quote approval process.
As the first step, I tried to create a simple workflow to trigger when a Quote item is saved/modified using Dataverse 'When a row is added, modified or deleted'. So, I have studied many online tutorials and done workflow very simple to send an email when a Quote item is saved/modified.
Problem is, It's actually not triggered with any action on the Quote page. Already spend a couple of days to figure out the issue.
This is how I tested it.
Step 01 - Save and test manually test flow
Step 02 - insert a new item to Quote or modify the existing item.
But nothing happens.

Items you add to the Quote are in fact Quote Product records. This is a separate table named quotedetail.
Your Power Automate flow needs to target the Quote Products table to capture the intended changes.

The reason was Administrative mode.
Administrative mode disables all asynchronous processes. This includes server-side sync (email synchronization) and workflow processes including flow (Power Automate).
https://functionalthoughts.com/microsoft-dynamics-365-managing-admin-mode-from-power-platform/

Related

Flow Triggering Itself(Possibly), Each run hits past IDs that were edited

I am pretty new to power automate. I created a flow that triggers when an item is created or modified. It initializes some variables and then does some switch cases to assign values to each of them. The variables then go into an array and another variable is incremented to get the total of the array. I then have a conditional to assign a value to a column in the list. I tested the flow specifically going into the modern view of the list and clicking the save button. This worked a bunch of times and I sent it for user testing. One of the users edited multiple items by double clicking into the item which saves after each column change(which I assume triggers a run of the flow)
The flow seemingly works but seemed to get bogged down at a point based on run history. I let it sit overnight and then tested again and now it shows runs from multiple IDs at a time even though I only edited one specific one.
I had another developer take a look at my flow and he could not spot anything wrong with it and it never had a hard error in testing only warnings about conditionals causing a loop but all my conditionals rectify. Pictures included. I am just not sure of any caveats I might be missing.
I am currently letting the flow sit to see if it finishes getting caught up. I read about the concurrent run option as well as conditions on the trigger itself. I am curious as to why it seems to run on two records(or more) all at once without me or anyone editing each one.
You might be able to ignore the updates from the service account/account which is used in the connection of the actions by using the following trigger condition expression:
#not(equals(triggerOutputs()?['body/Editor/Claims'], 'i:0#.f|membership|johndoe#contoso.onmicrosoft.com'))

Dynamics CRM - Copy Workflow for a different entity

I'm relatively new to Microsoft Dynamics CRM (which has changed to Microsoft Dynamics 365).
I currently have an issue where I need to redo some of the processes of an existing workflow for an existing entity, to another entity. This task in itself is very time consuming and rather tedious.
I thought that it may be possible to duplicate the workflow and update the entity, but that does not seem possible, but only for the same entity - https://community.dynamics.com/crm/b/altavistatechnology/posts/duplicating-workflow-in-dynamics-crm
Is there a way for me to either reuse, or somehow quicken the process of doing these tasks? The process is to have multiple check conditions for numerous values and update a field in the form, if those conditions have been met.
Unfortunately, this Workflow template concept is only option to copy/save-as/clone the WF logic into a new WF, and this supports only within the same entity.
There may be unsupported approaches to extract the solution xml/xaml & have some adventurous efforts for overcome this. But that's not recommended & you may not see lot of documentation for that path.
That's the benefit of using Custom workflow activity, custom action or Plugin to do reusable code blocks, but this UI WF copy across entities is not a viable option by OOB.
Depending upon the logic, you can try child workflow concept which can be reused. But not sure if that works on your case without seeing the logic implemented.
I didn't know that I could have multiple values within the field (as I kept creating a new check condition for each individual value, but the field can take multiple values separated by a ; )
So this had helped quicken the process (as I did create multiple check conditions which I did find silly....)

Select Business Process Flow Stage onChange of a Field Value

I am trying to update a business process flow stage using Workflow or JavaScript.
First I tried with JavaScript using below method,
Xrm.Page.data.process.moveNext(onSetActiveStage);
But the problem with this method is if the active stage is greater than the required selected stage then moveNext logic will not work.
I know I can use movePrevious as well but it will be another overhead as sometime the active stage will be before the required stage and sometime it will be after.
The other option for me was on some field change I can use a workflow to activate or select a stage on business process flow.
For that I created a workflow and selected my BPF as my entity and selected a field on Process Change.
And inside my Set Properties, I set Active stage as the required stage which I want to mark as active.
The above logic is not working for me on change of the field.
I am new to BPF, please bear with me if I am making some basic mistake.
If you are following this blogpost, the comments below the post says - it's not working/triggering for custom BPF and you have to refresh the form to see the changes. Make sure if this is what affecting you.
Also you can un-check the "Workflow Job Retention" checkbox for troubleshooting to see if its triggering or not.
Btw, your design seems to be little confusing, required stage before/after active stage does not makes sense. You may need to add the different branch and "Data step" to make it required in different scenarios.
If this is not feasible, then try to use scripting to set the active stage or plugin/custom action to set the stage on your trigger.

Maximo: Use script to update work order when a related table is updated

I have an automation script in Maximo 7.6.1.1 that updates custom fields in the WORKORDER table.
I want to execute the automation script when the LatitudeY and LongitudeX fields (in the WOSERVICEADDRESS table) are edited by users.
What kind of launch point do I need to do this?
Edit:
For anyone who's learning automation scripting in Maximo, I strongly recommend Bruno Portaluri's Automation Scripts Quick Reference PDF. It doesn't have information about launch points, but it's still an incredibly valuable resource.
I wish I'd known about it when I was learning automation scripting...it would have made my life so much easier.
You can create an attribute action launch point on the latitudeY field and another on the longitudeX field. These will trigger whenever each field is modified, so it will fire once when the latitudeY field was changed, again if the longitudeX field is changed, again if the longitudeX field is changed again, and so on. This is also all before the data is saved, so the user may choose to cancel their changes, but the scripts will still have fired.
You could also make an "on save" object launch point for WOSERVICEADDRESS (if that's what is actually being updated via the map). This will run any time data in the object is saved, so you would have to do the extra checks of seeing if either of those fields have changed and then do your logic, but at least it would run once and only if the user commits to their changes.
Related:
Populates WORKORDER.WOSAX and WORKORDER.WOSAY (custom fields) from the values in WOSERVICEADDRESS.LONGITUDEX and WOSERVICEADDRESS.LATITUDEY.
woMbo=mbo.getOwner()
longitudex=mbo.getString('longitudex')
latitudey=mbo.getString('latitudey')
if woMbo is not None:
wosax=woMbo.getString('WOSAX');
wosay=woMbo.getString('WOSAY');
if longitudex!=wosax:
woMbo.setValue('WOSAX',longitudex)
if latitudey!=wosay:
woMbo.setValue('WOSAY',latitudey)
The launch points are Attribute Launch Points, not Object Launch Points.

Why is infinite loop protection being triggered on my CRM workflow?

Update
I should have added from the outset - this is in Microsoft Dynamics CRM 2011
I know CRM well, but I'm at a loss to explain behaviour on my current deployment.
Please read the outline of my scenario to help me understand which of my presumptions / understandings is wrong (and therefore what is causing this error). It's not consistent with my expectations.
Basic Scenario
Requirement demands that a web service is called every X minutes (it adds pending items to a database index)
I've opted to use a workflow / custom entity trigger model (i.e. I have a custom entity which has a CREATE plugin registered. The plugin executes my logic. An accompanying workflow is started when "completed" time + [timeout period] expires. On expiry, it creates a new trigger record and the workflow ends).
The plugin logic works just fine. The workflow concept works fine to a point, but after a period of time the workflow stalls with a failure:
This workflow job was canceled because the workflow that started it included an infinite loop. Correct the workflow logic and try again. For information about workflow logic, see Help.
So in a nutshell - standard infinite loop detection. I understand the concept and why it exists.
Specific deployment
Firstly, I think it's quite safe for us to ignore the content of the plugin code in this scenario. It works fine, it's atomic and hardly touches CRM (to be clear, it is a pre-event plugin which runs the remote web service, awaits a response and then sets the "completed on" date/time attribute on my Trigger record before passing the Target entity back into the pipeline) . So long as a Trigger record is created, this code runs and does what it should.
Having discounted the content of the plugin, there might be an issue that I don't appreciate in having the plugin registered on the pre-create step of the entity...
So that leaves the workflow itself. It's a simple one. It runs thusly:
On creation of a new Trigger entity...
it has a Timeout of Trigger.new_completedon + 15 minutes
on timeout, it creates a new Trigger record (with no "completed on" value - this is set by the plugin remember)
That's all - no explicit "end workflow" (though I've just added one now and will set it testing...)
With this set-up, I manually create a new Trigger record and the process spins nicely into action. Roll forwards 1h 58 mins (based on the last cycle I ran - remembering that my plugin code may take a minute to finish running), after 7 successful execution cycles (i.e. new workflow jobs being created and completed), the 8th one fails with the aforementioned error.
What I already know (correct me where I'm wrong)
Recursion depth, by default, is set to 8. If a workflow / plugin calls itself 8 times then an infinite loop is detected.
Recursion depth is reset every one hour (or 10 minutes - see "Warnings" in linked blog?)
Recursion depth settings can be set via PowerShell or SDK code using the Deployment Web Service in an on-premise deployment only (via the Set-CrmSetting Cmdlet)
What I don't want to hear (please)
"Change recursion depth settings"
I cannot change the Deployment recursion depth settings as this is not an option in an online scenario - ultimately I will be deploying to CRM Online too.
"Increase the timeout period on your workflow"
This is not an option either - the reindex needs to occur every 15 minutes, ideally sooner.
Update
#Boone suggested below that the recursion depth timeout is reset after 60 minutes of inactivity rather than every 60 minutes. Therein lies the first misunderstanding.
While discussing with #alex, I suggested that there may be some persistence of CorrelationId between creating an entity via the workflow and the workflow that ultimates gets spawned... Well there is. The CorrelationId is the same in both the plugin and the workflow and any records that spool from that thread. I am now looking at ways to decouple the CorrelationId (or perhaps the creation of records) from the entity and the workflow.
For the one hour "reset" to take place you have to have NO activity for an hour. It doesn't reset just 1 hour from the original. So since you have an activity every 15 minutes, it never has a chance to reset. I don't know that is said in stone anywhere... but from my experience.
In CRM 4 it was possible to create a CRM Service (Google creating a CRM service in the child pipeline) and reset the correlation ID (using CorrelationToken.NewToken()). I don't see anything so easy in the 2011 SDK. No idea if this trick worked in the online environment. Is 2011 online backwards compatible with CRM 4 plug-ins?
One thing you could try would be to use the IExecutionContext.CorrelationId to scavenge the asyncoperation (System Job) table. But according to the metadata, the attribute I think might be useful (CorrelationId, CorrelationUpdatedTime, Depth) are NOT valid for update. Maybe you could delete the rows? Even that may not help.
I doubt this can be solved like this.
I'd suggest a different approach: deploy a simple application alongside CRM and let it call the web service, which in turn can use the XRM endpoints in order to change the records.
UPDATE
Or, you can try something like this upon your crm service initialization in the plugin (dug it up from one of my plugins) leaving your workflow untouched:
CrmService service = new CrmService();
//initialize service here, then...
CorrelationToken newtoken = new CorrelationToken();
newtoken.CorrelationId = context.CorrelationId;
newtoken.CorrelationUpdatedTime = context.CorrelationUpdatedTime;
// WILD GUESS: Enforce unlimited depth ?
corToken.Depth = 0; // THIS WAS: context.Depth;
//updating correlation token
service.CorrelationTokenValue = corToken;
I admit I don't really remember much about this (code dates back to about 2 years ago), but it might help.

Resources