tech
Nintex Newbie

POST request in Nintex Forms javascript to save data to sharepoint lists

Hi All,

 

I am working on a POC which is really very urgent for me. As per the requirement,the scenario is to save data from a nintex form to multiple lists. To achieve this, I am using javascript code with REST api to insert a new item to sharepoint list, but the issue is it gives this error message in browser console on POST request: "Failed to execute 'postmessage' on DOMWindow':The target origin provided('URL') does not match the receipient window's origin ('null')."

I am not getting any solution to use javascript to insert records all over the internet and Nintex community. Kindly help and let me know if there is any other alternative to save data to multiple lists from the nintex form.

 

Thanks..!!

0 Kudos
Reply
3 Replies
emha
Automation Master
Automation Master

Re: POST request in Nintex Forms javascript to save data to sharepoint lists

could you post how does your request looks like?

 

"receipient window's origin ('null')" => sounds like you haven't provided a required value.

0 Kudos
Reply
tech
Nintex Newbie

Re: POST request in Nintex Forms javascript to save data to sharepoint lists

Thanks for replying.. My javascript looks like below:

function save() {


NWF$('.saveButton').click();


var Client = NWF$(".nsClient option:selected").text();
var CaseType = NWF$(".nsCaseType option:selected").text();
var FundDate = NWF$(".nsDate input").val();
var Plan = NWF$(".nsPlan option:selected").text();

var hostweburl = decodeURIComponent(getQueryStringParameter("SPHostUrl"));
var addNewItemUrl = hostweburl + "/_api/Web/Lists/GetByTitle('Onboarding')/Items";

alert(hostweburl);
alert(addNewItemUrl);

var data = {
__metadata: {
'type': 'SP.Data.SpListItem'
},
Client: Client,
Case_Type: CaseType,
Estimated_Funding_Date: FundDate,
Plan: Plan


};
alert("Before item addition");
addNewItem(addNewItemUrl, data, hostweburl);
}


function addNewItem(addNewItemUrl, data, hostweburl) {
var executor = new SP.RequestExecutor(hostweburl);
executor.executeAsync({
url: addNewItemUrl,
type: "POST",
headers: {
"accept": "application/json;odata=verbose"
},
data: JSON.stringify(data),
success: function(data) {
console.log("Item Created");
console.log(data);
},
error: function(error) {
console.log(JSON.stringify(error));
}
});

}

0 Kudos
Reply
emha
Automation Master
Automation Master

Re: POST request in Nintex Forms javascript to save data to sharepoint lists

first spot: enclose data properties and field names in apostrophess and test ...

 

...
'__metadata': ...
'Client': Client
...

i.jpg

 

 

 

0 Kudos
Reply