Updating a related task
Original Post by Thong Kha (Imported from Ardevia Forum)
I know this is a long shot, but I figured I'd try.
Is there a method of updating a task related to a list item? I'm trying to allow users to approve or reject tasks related to a list item just using the Ardevia form, instead of having to manage the task as well as the list item.
Any help or nudge in the right direction would be appreciated!
-
Original Post by dany (Imported from Ardevia Forum)
This can be accomplished quite easily by adding a list item update action on the save button to set values on the related list item:
- In design mode for the form double click the Save button to select it
- In the Rich Forms Behavior ribbon tab select Edit in the Actions actions
- In the Actions Builder add a new action
- Move the new action before the default Redirection action
- Set the type of the action to "Update list item"
- Set the list to the related list to be updated (i.e. tasks)
- Use the following expression for the List Item Id parameter of the action:=[[@Web.GetFirstValueForQuery('Tasks', '<Where><Eq><FieldRef Name="LookupField" LookupId="TRUE"/><Value Type="Lookup">[[ID]]</Value></Eq></Where>', 'ID')]]
where "Tasks" is the name of the related list and "LookupField" is the internal name of the lookup field referencing the forms list from the related list.
- Set the appropriate values (using expressions) to update on the action (leave fields empty where value should not change)
- Save the form
--> Now whenever the form is saved the first related item is updated with the appropriate values0 -
Original Post by Thong Kha (Imported from Ardevia Forum)
Hi Dany,
Thank you for the response.
I tried creating an Update List Item action on the "Workflow Tasks" list. In the "Content Type" dropdown of the action, I don't have "Workflow Task" as an option, so I selected Task.
I don't see where I can update the "Task Outcome" (Approved or Rejected) field anywhere in the list of fields to update in the action. That field only seems to be in the Workflow Task content type. Is there a workaround available for this?
Thanks.
0 -
Original Post by Vitaliy Zadorozhnyy (Imported from Ardevia Forum)
Hi,
You can use "Execute Script" to update field of hidden content type.
To achieve this follow next steps:- In design mode for the form double click the Save button to select it
- In the Rich Forms Behavior ribbon tab select Edit in the Actions .
- In the Actions Builder add a new action of Type "Execute Script"and move it just after Save Form Action.
- Remove "Redirection" Action so new action should be last.
- Paste the code below to script action text area.
Code:
var ctx = new SP.ClientContext(); var web = ctx.get_web(); var list = web.get_lists().getByTitle('Tasks'); var listItem = list.getItemById([[@Web.GetFirstValueForQuery('Tasks', '<Where><Eq><FieldRef Name="LookupField" LookupId="TRUE"/><Value Type="Lookup">[[ID]]</Value></Eq></Where>', 'ID')]]); listItem.set_item('TaskOutcome', 'Approved'); //listItem.set_item('<FieldName>', '<Value>'); listItem.update(); ctx.executeQueryAsync(function(){ //Redirect from the form Ardevia.Common.DefaultNavigationHelper.Redirect(); }, function(){ alert('fail'); });
where "Tasks" is the name of the related list and "LookupField" is the internal name of the lookup field referencing the forms list from the related list.0
Please sign in to leave a comment.
Comments
3 comments