Forum Discussion

Brent Ellis's avatar
Brent Ellis
Silver Contributor
Dec 05, 2016
Solved

CSOM Update without triggering workflow - SharePoint Online

I seem to recall someone saying / writing that updates were coming to SharePoint Online CSOM where you could update a list item without triggering workflows (like you can on prem), did that ever come to fruition?

  • Hi there,

     

    SystemUpdate is presented in CSOM/JSOM too, actually. It was added in SPO sometime before and seems like it works very close to SSOM's method:

     

    • No editor and modified date information is updated,
    • No version is created,
    • But workflow with an on edit trigger, unfortunately, starts,
    • Not sure about RERs, likely they are fired as well.

     

    Here is a sample in JavaScript (should be executed on classic display or edit form):

     

    var clientContext = new SP.ClientContext.get_current(); 
    var oList = clientContext.get_web().get_lists().getById(_spPageContextInfo.pageListId);
    var oListItem = oList.getItemById(GetUrlKeyValue("ID"));
    oListItem.set_item('Title', 'New title');
    oListItem.systemUpdate();
    clientContext.executeQueryAsync(
        function() {
            console.log('Item has been updated');
        },
        function(sender, args) {
            console.log('Error: ' + args.get_message() + ' ' + args.get_stackTrace());
        }
    );

    Didn't check if the CSOM (C#) behavior is the same.

    Anyway, maybe it will be helpful.

11 Replies

  • Russell Gove's avatar
    Russell Gove
    Iron Contributor
    Vesa mentioned on the PNP-JS call today that there was an update in the November CSOM release that would let you do a systemupdate from csom without triggering workflows.
  • Hi there,

     

    SystemUpdate is presented in CSOM/JSOM too, actually. It was added in SPO sometime before and seems like it works very close to SSOM's method:

     

    • No editor and modified date information is updated,
    • No version is created,
    • But workflow with an on edit trigger, unfortunately, starts,
    • Not sure about RERs, likely they are fired as well.

     

    Here is a sample in JavaScript (should be executed on classic display or edit form):

     

    var clientContext = new SP.ClientContext.get_current(); 
    var oList = clientContext.get_web().get_lists().getById(_spPageContextInfo.pageListId);
    var oListItem = oList.getItemById(GetUrlKeyValue("ID"));
    oListItem.set_item('Title', 'New title');
    oListItem.systemUpdate();
    clientContext.executeQueryAsync(
        function() {
            console.log('Item has been updated');
        },
        function(sender, args) {
            console.log('Error: ' + args.get_message() + ' ' + args.get_stackTrace());
        }
    );

    Didn't check if the CSOM (C#) behavior is the same.

    Anyway, maybe it will be helpful.

    • Brent Ellis's avatar
      Brent Ellis
      Silver Contributor
      also thanks, i knew something like that was out there (shame tho I was more interested in bypassing the workflows), but still useful
    • Russell Gove's avatar
      Russell Gove
      Iron Contributor

      Thanks for the info Andrew-- I had no Idea they added that to the CSOM!

      Still seems like it could be a security issue if a user can update any metadata on a list without having temselves tagged as the last update user.

      • Andrew Koltyakov's avatar
        Andrew Koltyakov
        MVP

        I believe that a user should be a member of Site Owners or site collection admin to be able to execute systemUpdate.

  • Anonymous's avatar
    Anonymous
    and hue.. it is not GA yet... only first release preview
    • Brent Ellis's avatar
      Brent Ellis
      Silver Contributor
      No, i don't believe it was webhooks. It was definitely discussed on Yammer, can't find any record of it anywhere else.

      This is apparently a thing in on premise, maybe in on prem CSOM it's called a SystemUpdate()

      I believe it would allow you to run scripts without incrementing versioning or triggering workflows on item changes.
      • Russell Gove's avatar
        Russell Gove
        Iron Contributor

        SystemUpdate is not available in CSOM on prem, it's only in the server side object model.  it allows you to update items without affecting last update user /time or running workflows.  It is meant to be used by trusted code.  I guess it's not in the csom because if it were, anyone who had update authority to a list would be able to make a simple ajax call from their browser and change the last update user/time or running any workflows, 

         

        there would have to be some changes to the security model before they would ever allow this in the csom.

  • Anonymous's avatar
    Anonymous
    You mean webhooks i guess a new way of triggering events in lists

Resources