Code to write Custom logic once user add any item in custom list in SharePoint 2013 Online (Office 365 E3 version).

Hi,

 

We need to write some custom logic once user add any item in custom list in SharePoint 2013 Online (Office 365 E3 version).

 

Any approach, information, code about this would be greatly appreciated. Thanks!

July 20th, 2015 12:14pm

Overwrite PreSaveAction() in custom JavaScript when submitting SharePoint ListForms.
You can add it content Editor webpart.
Free Windows Admin Tool Kit Click here and download it now
July 20th, 2015 3:25pm

Thanks, can you please share some article for this
July 21st, 2015 2:02am

Hi Shailendra,

There are two different approaches we can follow

1) PreSaveAction() - Executing certains logics before saving the item to list

https://social.technet.microsoft.com/Forums/sharepoint/en-US/86fe14fc-f353-4521-bf88-fd7fcabaa768/using-presaveaction-in-newformaspx-in-sharepoint-list?forum=sharepointgeneralprevious

2) ItemAddedEvent Receiver - Execute custom logic after adding item to the list.

http://onceinawhilescribble.blogspot.in/2013/05/creating-simple-event-receiver-in.html

Thanks.

Free Windows Admin Tool Kit Click here and download it now
July 21st, 2015 2:34am

Hello Shailendra,

You can add some JS logic in CEWP on your new/edit list forms something like below.

<script src="/sites/dev/Style%20Library/Custom/Grid/jquery.min.js"></script>
<script type="text/javascript">
function PreSaveAction() {
    if ($("select[title='Status'] option:selected").val() == 'Closed') {
        alert("You can't reopen this item")
        return false;
    } else {
        return true;
    }
}
</script>

Thanks.

July 21st, 2015 6:52am

Hi,

Thanks, can we use this code in Sp13 Online version, also we don't have Azure?

Free Windows Admin Tool Kit Click here and download it now
July 21st, 2015 7:49am

Yes, you can use it in SP2013 Online.

Thanks.

July 21st, 2015 9:35am

Thanks, what is option for post save action in SP2013 Online.
Free Windows Admin Tool Kit Click here and download it now
July 21st, 2015 11:08am

Hi,

I suppose there is no method called PostSaveAction.

If you wanna do certains action after saving the item, use event receiver or workflow based on your requiremnt.

Thanks.

July 21st, 2015 11:59pm

Hi,

Few different options:

  • Remote Event Receiver: downside is you need to host your code in a separate web site and since you don't have azure, the only option is a public web site hosting. And also complex in terms of development and expensive in terms of deployment.
  • Workflow: I think a custom workflow will be the best option but depends if your custom code logic can be implemented efficiently in workflow.
  • PreSaveAction: This is hacky solution and the function is not documented. So it might happen the hacky solution work today but if tomorrow Microsoft changes the implementation (say, function name is changed) and deploy, your code will not work. And it happens a lot in SP Online, if you don't follow the best practices/guidelines.

So I would like to suggest to check workflow solution.

Free Windows Admin Tool Kit Click here and download it now
July 22nd, 2015 2:02am

This topic is archived. No further replies will be accepted.

Other recent topics Other recent topics