Skip to main content

Search

Updating a related task

Comments

3 comments

  • ArdeviaForum

    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 values

    0
  • ArdeviaForum

    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
  • ArdeviaForum

    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:

    1. In design mode for the form double click the Save button to select it
    2. In the Rich Forms Behavior ribbon tab select Edit in the Actions .
    3. In the Actions Builder add a new action of Type "Execute Script"and move it just after Save Form Action.
    4. Remove "Redirection" Action so new action should be last.
    5. 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.