I have a task to implement an Azure Function which is triggered by an HTTP-Webhook defined in Microsoft DevOps (VSTS).
The idea is as follows:
We have a backlog-structure (let's say: Epic > Feature > User Story > Task)
If i set the state of any of those items to 'Done', all underlying items should also change to 'Done'
What i have done so far
I have enabled a webhook in DevOps which triggers on update of any workitem and sends this item as JSON to an Azure Function
I have written the Azure Function which is invoked by an HTTP-request and get's the URL of the item which has triggered the request
The function then gets all items which are a child of the first workitem
The function patches all found child items with the state of the first item
All direct children are updated on DevOps
What i need
I'm trying to figure out an option to enable recursive update. Not only direct children should be updated, but also all their children (if they have some) and so on.
I thought about the following ways to accomplish this and need your guidance:
Get all direct children as JSON and then send HTTP-request's to the same function, passing all child item's
call the function within the function (don't even know if this works) and pass the children as JSON
find a way to handle all the logic in this single function (dumb foreach-nesting to ensure all backlog-hierarchy levels are processed)
If any code snippets are needed just tell me and i will provide the requested parts (right now i'm quite unsure what part of my code i should publish and would be helpful)
From your list of approaches:
Get all direct children as JSON and then send HTTP-request's to the
same function, passing all child item's
[Please see Fan-Out/Fan-In scenarios in Durable functions. This will achieve what you are looking for]
call the function within the function (don't even know if this works)
and pass the children as JSON
[This is not recommended. Please see here for best practices]
find a way to handle all the logic in this single function (dumb
foreach-nesting to ensure all backlog-hierarchy levels are processed)
[Same here. This is not recommended. In general it best practice to avoid long running functions]
Related
I am trying to resolve this error in Power Automate:
Actions in this flow may result in an infinite trigger loop.
Please ensure you add appropriate conditional checks to prevent this flow from triggering itself.
This seems to be a common problem when using this trigger:
When an item is created or modified
where the associated flow contains this action:
Update item
The dynamic is succinctly explained in these videos here and here.
Desired Behaviour
The desired behaviour is that the flow:
Runs when a list item is created or modified by a user (and updates the item accordingly)
But not when the flow itself updates the item
Actual Behaviour
The actual behaviour is that the flow:
Runs when a list item is created or modified by a user (and updates the item accordingly)
Also runs when the flow itself updates the item (causing an infinite loop)
What I've Tried
Some posts suggest using a Service Account to run the flow and then apply the logic:
If the flow was triggered by a Service Account, terminate the flow
But I do not have access to a service account in this scenario.
The simplest solution seems to be answers like this one and this one.
They suggest creating a column in the SharePoint List to store a 'flag'.
I understand the concept of using flags to indicate:
DO run the flow if SOME_FLAG is false
DO NOT run the flow if SOME_FLAG is true
But I am having trouble when it comes to implementing them properly in this scenario.
Specifically, I have added a Yes/No column to my List called LastModifedByFlow.
The default value is No (i.e. false).
My flow is structured like this:
01) TRIGGER: When an item is created or modified
02) I have added this Trigger Condition
#equals(triggerBody()?['LastModifiedByFlow'],false)
03) This means the flow will run when LastModifiedByFlow is false
04) Create some variables
05) ACTION: Update the item - this includes setting the LastModifedByFlow value to true
Question
The first time the flow runs, it works great:
the item is updated
the item's LastModifedByFlow value is set to true so the flow doesn't run again
But how and where in the flow do I set the LastModifedByFlow value back to false?
So that the flow will run each time a user subsequently modifies the list item?
It is recommended that you set a default value of “Yes” for the Yes/No column first. When the item is created, the flow will be triggered. After the flow is completed, the value of the column "Yes" will become "No". When the item is modified, it is recommended to manually change "No" to "Yes" to trigger the flow. Here is a post for your reference.
I want to know if we can have a parent workflow which when called leads to spawning of multiple child workflows. Is there a way we can actually implement it in SharePoint. So basically I want to use a part of my parent workflow to trigger another workflow - this particular workflow can be associated to the same list and sometimes they can be associated with different lists and libraries...will that cause any problems.
It would be awesome if you guys can share your thoughts and ideas regarding this topic.
So how I expect it to work :-
Let's say when something triggers workflow A it goes and spawns multiple items in the SharePoint list which triggers workflow B. And all the newly created items are running workflow B. Also if there is a way to call another workflow C which is linked to another library.
If you are using SharePoint 2013 or later:
Add a column to the list with a name like WFBtrigger or WFBstatus. Set it to default to "" or "Not run" or similar.
Create your Workflow A. When it's finished have it update WFBstatus to "Pending" or similar.
Create your Workflow B. Set it to start when the item is created. Add a Loop. In the loop wait for WFBstatus to change to "Pending". Do "B's" work. Update the WFBstatus field to "Done".
Now when A is triggered, B will shortly there after run.
To trigger C in another list, just have A or B update a "WFCstatus" column in the C list and have a workflow C waiting for that column to change.
So I have got some great news ! I was able to figure this one out but It is not exactly very direct
So SharePoint Designer allows you to create an item in another list using the create function. I have attached a screenshot
click here to view
So using this functionality you can create an item in a completely different list or the same list. But this has one problem- Once you actually create an item on the child list using a 2013 workflow it will not trigger the workflow in the child list. So this has been explicitly disabled to prevent a condition called Workflow recursion. So is there a way around it ?
Yes ! you have two options:-
1.Call the Rest Endpoint for the child workflow, Sample approach : https://blogs.msdn.microsoft.com/sridhara/2014/08/21/fix-sharepoint-2013-workflow-recursion-prevention-part-2/
2.Use MS Flow to create the flow in the child list
Hopefully it helps someone out there !
PS: For some weird reason for our company we cannot create 2010 workflows- apparently 2010 workflows are not supported in modern sites (I maybe misinformed)
Currently trying to work out how to use REST API to execute an action.
I added the ReverseInvoice action from Bills screen on my endpoints. And seems execute fine. Unfortunately, executing an action does not return a result e.g. 204 No Content. I'd wish to extract the RefNbr of the Debit Adj. raised.
Second problem is how do you stack actions or call series of actions ? The raised Debit Adj is not Released. So it seems ReverseInvoice & Release need to be executed at the same time. Plus, I also need them to be allocated against each other automatically.
I've got a feeling the REST API is not the way to go with this one.
Cheers and thanks for responses.
Unfortunately, you're correct on both points: Acumatica's Contract-based API (both SOAP and REST flavors) doesn't allow you to get the entity that is a result of an action (you can only get the status of action invocation), and if you want to chain a sequence of action you'll have to do that manually from the client (call one action, check for the status, call the second one, check, raise, rinse, repeat). Or you can write a customization with a custom action that call two actions in sequence, and call that from the API.
I have created state workflow in Sharepoint.
My idea is:
1/ when workflow is started create copy of list item on which workflow was started, this copy is created to another web list within current site collection - that's working
2/ monitor changes on parent item and propagate them to copied item - that's working
3/ monitor changes on copied item and propagate them back to original item - that's not working
I was trying to use IListItemService, but apparently it canno watch for changes on different then current web ? Is there any other way how to do it ?
I was thinking about SharePoint 2010 Pluggable Workflow Services - but in my class which derives from SPWorkflowExternalDataExchangeService method CallEventHandler was called twice even when only one call of SPWorkflowExternalDataExchangeService.RaiseEvent was made (this was called from custom event receiver) - another problem with this solution is when I recycle app pool I lost my singleton class which is responsible for maintaining list of state information needed for RaiseEvent method.
There is an event mechanism built into SharePoint just for this purpose. There's no need to use workflows or copy items.
Example: Creating a List Item Event Handler
I'm aware of the event receivers on a list for items added etc. However, I have not found a way to fire code upon the creation of a list.
What I'm trying to do is associate a workflow with a list when the list is created (by the user through the UI).
Anyone any ideas?
thanks.
There are a couple of routes you can take...
You can write your own list definition where you have defined the workflow association - That way all lists created based on your list definition, will contain your workflow on default.
Or... depending on your workflow... write an EventReceiver your attach to all lists of the type you wish to attach your workflow to (can easily be achieved tru a feature) and have your event receiver associate the workflow when the first item is added.
or you can associate the workflow to the contenttype used in the list (your own contenttype you attach to your own list definition or a default SharePoint contenttype)
I don't know the rest of your solution, so it's defficult for me to suggest the best solution for you.
What I (almost) always do, is write my own list definition - That way I can avoid problems like this, now or in the future.
With SharePoint 2010 it is now possible to hook into the list creation event by overriding the ListAdded event in the SPListEventReceiver class.
I usually deploy an extra view page which is set to the default view. When the user creates the list he will be sent to the viewpage which contains the setup in code behind. The view page then calls a method ive created, which changes the default view, removes the setup view and change any navigation node pointing to the setup view.
There is probably no perfect answer to this question because there is no list added event receiver (if memory serves me correct).
I don't know if this is the case, but if you really just needed to register an itemadded (or updated, deleted, etc.) event to any new list, I believe you can register the those events at the site (SPWeb) level and they will fire on any new lists created.