Javascript in Nintex to insert data into share point list

  • 22 March 2019
  • 6 replies
  • 107 views

Is there a way to insert calculated feild value in sharepoint list by using javascript. I know we can simply do this by mapping the filed using connected to option and then add submit button but i wanted this to be done with javascript based on change event occurs in dropdown list so basically i would be inserting this data into sharepoint list before submitting it. 

 

NWF.FormFiller.Events.RegisterAfterReady(function(){

NWF$('#' + jsDropdown).change(function(){

 

 // Get Value 

var calcfield = NWF$('#' + jsCalcField).val(); 

 

// How to insert value in SP list?

 

 

 });

});


6 replies

Badge +4

Hi,
I've similar issue - we are modifying item using SP REST (you can find many examples how to do it using js), but the issue is, that your item is updated in a parallel process and when you try to save the item again using the open edit form, the form noticed that the item has been changed since the form is open and don't override the changes. And this makes totaly sense to avoid overriding changes from other users who has changed the item.

So, AFAIK it isn't possible. Maybe if you would handle the whole saving process by yourself, reload the item just before saving and just override the changes. But it could have side effects...

Regards

 

P.S. Just noticed, that you asked this for O365. Sorry - my experience is for Forms on premise. No clue the behaviour is the same.

Hi, I'm still finding a way to insert items is sharepoint list either with Javascript/SP Rest API using JS but i'm unable to find so.  could be help me please.  Thanks

Badge +17

This is outside the supported function of Nintex forms. I'm not sure why you would want to submit data to the list before submitting the firm which would mean you would have a new item created and them modified when submitted.


 


Nintex forms has the option of save, save as and submit and or just submit. Is there a particular reason why this is not good enough? Again, pushing any value from a forms calculated field into a list but not using mapping seems like overkill and a poor workaround to standard functionality that will also render your form potentially at risk should you want to update Nintex in the future. 

To give a background  - We were using InfoPath and MS SQL in our project to get inputs form the end users and now we have switched to SharePoint and Nintex O365.  Multiple users will be using the form at same time and I have built a functionality to fetch a record from the SP list using Nintex workflow and Nintex form. The workflow will fetch a record which was not updated by the users. To do this I had to create a dependent list and set some validations.  It’s working as designed but at times there are some delays in inserting the items in list because of the delay the runtime functions aren’t picking up the recent inserted items. ( in another words if items are inserted in SP list within less than a second then it works but at times it takes little more than a second so the runtime formulas aren’t picking the updated ones)

 

To fix this, either I have to delay the form load time or insert some of the values in list based on an event (before submitting the form). If there is a way to dynamically delay the form like it should check if the items are updated in the list before it completes loading then this would work for me else the second approach is to have some of the field values inserted in the list before hitting submit button.   

Badge +17

So speaking candidly. I still dont quite understand why you would need to update a list before the form is filled out. 


 


Take for example project codes. The form is to complete an invoice against a project. But the project code needs to be added before the form can be submitted. You can use a choice column in SharePoint, allow other entries and it will take a new value if it doesn't already exist.


 


You also stated that many people will be filling out forms at the same time. I dont see this being a problem unless the data they are entering is key for everyone. If this is true, then you may want to design this entry process as two steps not one single form. The reason why I suggest this is, you are designing a flawed form when you're trying to "delay load" or query before showing new values. Browser type, internet speed and more will forever be your enemy and that's outside your control. So plan for that by guiding the user safely through data input.


 


Just my thoughts. A screenshot or expert of the form would be nice

I have same issue, I am trying to add a new item to another list in the Nintex form using Rest API. I have no luck so far. This is my code. It does success, but failed to add item - same code works in 2013



var   url = appweburl + "/_api/SP.AppContextSite(@target)/web/lists/getbytitle('ITA_Mailer')/items?@target='" + hostweburl + "'";   

     executor.executeAsync({

        url : url,

        type: "POST",

        body: reqData,



        headers: 

        { 

           "Accept": "application/json;odata=verbose"

           "Content-Type": "application/json;odata=verbose"

           "X-RequestDigest": NWF$("#__REQUESTDIGEST").val(),

            "X-HTTP-Method": "POST" 

        },

        success: function (data) {

           alert(JSON.stringify(data));

 



        },

Reply