0

I created a SharePoint list with a column having button as described here.

Now, I want to update another list item by clicking on this button.

The list look as above:

enter image description here

So, when I click on the "Start Workflow" button, it must add value in the "Updating" field.

1

For your requirement, you need to call a JSOM function and run the workflow on button click for corresponding list item.

Follow below steps:

  1. Create a SP designer workflow on this list and in its settings add trigger to manually run the workflow.
  2. Add update list item action in your workflow which will update the "Updating" field.
  3. Then add other actions to as per your requirements.
  4. In JSLink code you used to create a button, add a function to run the workflow using JSOM.
  5. On click of "Start Workflow" button, run this newly create function.

Check below references to create a JSOM function to run workflow.

References:

  1. Start SharePoint Designer Workflow 2013 using JavaScript

  2. Run SharePoint Workflow on Button Click in List Views using JSLink and JSOM

Alternate Solution:

You can create custom action button in your SharePoint list and run the workflow for particular list item on click of the custom action.

Source: Create A SharePoint Workflow Button

Update from Comments:

If you don't want to run workflow on button and update the same item then you can use JSOM or SharePoint REST API to update the corresponding list item.

Check below references for updating list item:

  1. CRUD Operations On A SharePoint List Using REST API
  2. Working with lists and list items with REST
  3. How to: Create, Update, and Delete List Items Using JavaScript
  4. Update A List Item In SharePoint Using JSOM
6
  • Hello Ganesh, start workflow is just name of button but there is no workflow connected to it. By clicking the button, respective list item "Updating" have to get a value (single line of text) – Rajana Deepak Jun 26 '20 at 8:18
  • Ok ,then you can use SharePoint REST API or JSOM to update the corresponding list item and set the value for Updating field (this will be easier solution as compared to running workflow on button click). – Ganesh Sanap Jun 26 '20 at 8:21
  • 1
    Check updated answer for more references on how to update list item using REST or JSOM. – Ganesh Sanap Jun 26 '20 at 8:26
  • Hello Ganesh, updated the code as per MS docs and it worked. But the issue is, we have to give list ID manually. Is there any chance that we get list id dynamically and update only that list item when the corresponding button is clicked? For Example, "If list id 2 button is clicked, only list id 2 Updating column must be modified" – Rajana Deepak Jun 26 '20 at 12:43
  • You can get the list item ID in your JSLink code using ctx.CurrentItem.ID. Then you can pass this ID to update the list item on button click – Ganesh Sanap Jun 26 '20 at 12:51

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.