AnsweredAssumed Answered

Nintex Form Javascript button using Rest API people picker value insertion

Question asked by mittu818 on Feb 21, 2018

I have a nintex form with a submit, cancel and one more javascript button. The main functionality I want to achieve using this javascript button is that when I click on it, the form should save (many fields) and the item should be added to the list and new form page should be loaded with a people picker field, drop down and single line text box of the previously entered values(nothing to do with the last saved item logic) which got save after clicking the javascript button and the form should be editable.

I have written the following code but able to  saved the item to the list but the people picker value is not inserted even though it's a mandatory field and new form redirection is not happening.


function submitandRequestAnother()
{
alert("Make");
var col1=NWF$('#'+jsEemailVal).val();
var col2=NWF$('#'+jsPickupLocation).val();
var col3=NWF$('#'+jsBuildingPickupLocation).val();
var col4=NWF$('#'+jsPickupContact).val();
var col5=NWF$('#'+jsFloorOfficeNumberandPost).val();
alert("Show Values:"+col2+" "+col3+" "+col4+" "+col5);
//alert(col1);

var addNewItemUrl = _spPageContextInfo.webAbsoluteUrl+"/_api/Web/Lists/GetByTitle('SpTest')/Items";
var data = {
__metadata: { 'type': 'SP.Data.SpListItem' },
EmployeeEmail: col1,
PickupLocation: col2,
BuildingPickupLocation: col3,
PickupContact: col4,
FloorOfficeNumberandPost: col5
};
alert("Before item addition");
addNewItem(addNewItemUrl, data);
}

function addNewItem(addNewItemUrl, data)
{
$.ajax({
url: addNewItemUrl,
type: "POST",
headers: {
"accept": "application/json;odata=verbose",
"X-RequestDigest": $("#__REQUESTDIGEST").val(),
"content-Type": "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));
}
});
}

How to insert the people picker value into list item and retrieve it and how to get the previous values duplicated by redirecting to new form and getting the values.

Manfred Lauer Vadim Tabakman Shirin PatelAlex VieraJohn Charles

Outcomes