Hi Team,
I have below query
$pnp.sp.web.lists.getByTitle("Testlist").items.add({
MPLineOfBusiness:_lineOfBusiness,
MPPolicyType:_policyType
});
alert("Your Data has been saved sucessfully");
window.location.href=urlofcurrentsite+"/SitePages/Test.aspx";
After this add i want to redirect the page back to the item which is created during this add event.
Example: during item add an item got createdwith id#"10". Immediately i need to redirect back to item#10 with saved data.
Could you please assist me how to redirect.
Oh, immediately, ok 馃槃
import { sp } from '@pnp/sp';
const list = sp.web.lists.getByTitle('CustomList');
list.items.add({ Title: 'My Item' })
.then((r) => {
const id = r.data.Id;
console.log(`Do whatever you need knowing the ID: ${id}`);
})
.catch(console.warn);
Oh, immediately, ok 馃槃
import { sp } from '@pnp/sp'; const list = sp.web.lists.getByTitle('CustomList'); list.items.add({ Title: 'My Item' }) .then((r) => { const id = r.data.Id; console.log(`Do whatever you need knowing the ID: ${id}`); }) .catch(console.warn);
$pnp.sp.web.lists.getByTitle("Testlist").items.add({
MPLineOfBusiness:_lineOfBusiness,
MPPolicyType:_policyType
}).then(function(resultdata) {
var idvalue = resultdata.data.Id;
window.location.href=urlofcurrentsite+"/SitePages/Test.aspx?TestID=idvalue ";
});
Is this correct?
Logically yes, technically - no. window.location.href=urlofcurrentsite+"/SitePages/Test.aspx?TestID=idvalue "; contains errors. However all of these is out of the scope on PnPjs library issues topics, but general development questions: Promises, strings concatenation, meh. We encourage asking general dev topics outside the repository's issues list, such as forums, gitter, tech community, etc. Thanks for understanding!
Logically yes, technically - no.
window.location.href=urlofcurrentsite+"/SitePages/Test.aspx?TestID=idvalue ";contains errors. However all of these is out of the scope on PnPjs library issues topics, but general development questions: Promises, strings concatenation, meh. We encourage asking general dev topics outside the repository's issues list, such as forums, gitter, tech community, etc. Thanks for understanding!
I have one more question could you please assist me. I have json result. I have few null vaues in it. Can i remove null value and make it empty.
$pnp.sp.web.lists.getByTitle("MPPolicyList").items.select("MPLineOfBusiness","MPPolicyType","Created","Modified","Author/Title","Editor/Title").filter("ID eq '"+_Itemid+"'").expand("Author","Editor").get().then(function(results){
for(i=0; i
_policyType=results[i].MPPolicyType;
_claimPaymentType=results[i].MPClaimPaymentType;
_Track=results[i].MPTrack;
});
if i have null value in _policytype,_claimPaymentType how can i remove it. Please assist me.