fd.spSaved or fd.spBeforeSave to submit form and get the new itemid that was created and update another list

Hi All,
I'm pretty new to plumsail but getting there slowly and hope to get some help here.
I would like to update another list with the new itemid record returned after i click the save button
.
As you can see below in my fd.spBeforeSave it works no issue but i can't get to retrieve the new itemid

But in the fd.spSaved I can get the newly created itemId but i can't get to retrieve some field values that i need to update in the other list

How can i achiwve this and thanks in advance

fd.spBeforeSave(function () {

    //It seems i can't get the itemid that was newly created here in the fd.spBeforeSave
    //var itemId = result.Id;
    //console.log(itemId);
    
    var Status = "Yes";
   //But i can get the field values from my form
    var RecordID = fd.field('RecordID').value;

    update(FormURL,Status,RecordID);
    
});


fd.spSaved(function (result) {
    
     //It seems i can get the itemid that was newly created here in the fd.spSaved
    //var itemId = result.Id;
    //console.log(itemId);

   //But i can't get this field values from my form here in the fd.spSaved
   var RecordFKID = fd.field('RecordID').value;

    var Status = "Yes";
    var RecordFKID = fd.field('RecordID').value;
    update(siteFormURL,Status,RecordID);
   

});

Hello @ninjacoder,

Welcome to Plumsail Community!

To update list another item you need to use the PnPjs library.

You can find the example on how to call PnP function inside spSaved event in this post:

Thanks for the prompt reply mnikitina.
I know how to update and i have a function called update in my original post.

See below
function update(FormURL,Status,RecordFKID) {
let web = new Web(FormURL);

var list = pnp.sp.web.lists.getByTitle("Test");

list.items.getById(bkRecordFKID).update({
    Status: Status,
    RequestFKID: "454" // hardcoded value

}).then(function () {

    console.log("Updated!");

});

}

The issue is how can i access values in my form e.g
var RecordID = fd.field('RecordID').value in the fd.spSaved as i need these values to be updated in another list.
As i said in my original post i know i can get the itemId

Thanks

@ninjacoder,

Thank you for the clarification!

Only the item ID is available inside spSaved() event. You can get item field values using the PnPjs function and then update another list item:

pnp.sp.web.lists.getByTitle("My List").items.getById(1).get().then(function(item){
  return item
}).then(function(item){ 
    pnp.sp.web.lists.getByTitle("List Name").items.getById(itemID).update({
        Title: item.Title
    });
});