Select Business Process Flow Stage onChange of a Field Value - dynamics-crm

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.

Related

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

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/

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....)

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.

Any Logic 6: event triggered sourced using conditions

I am building a model simulating an order process tiggering a production flow. The production flow should be initiated once the order is placed. My idea is to use an event named "start production" that is monitoring a boolean, which is changed by the above order entity.
I am facing various issues:
When starting the simulation my startProduction variable is changing from its initial value false to true already applying the starting condition in the event
If I apply in the action of the event the command event.restart() the simulation crashes as anylogic is constantly re-checking the event condition
How can I either solve the above problems or simulate the start of production based on an order income with a conditional logic?
Since my comment was the answer, let me add the answer here too.
It is always possible to use an event to trigger actions in your model, but it's also the most ineffective way, because you constantly running code that you may not need, making your simulation slower. The best thing you can do, whenever possible is to trigger things in the actions of your blocks. In this case when the order is generated you can use the inject function to add an agent to your production flow.
On the other hand, you can only use the restart function if the mode of your event is "user control" and it's probably the reason why you were getting an error.

Resources