Expand my Community achievements bar.

Submissions are now open for the 2026 Adobe Experience Maker Awards
SOLVED

Unable to update the Recipient record using Javascript xtk.session.Write in WebApp using ACC V8 client console

Avatar

Level 2

Hi Team,

I have created WebApp with Input Form with FirstName, LastName, Email in 1st page. And some Check box inputs in 2nd page.

my WebApp workflow configured like below.

SantoshKa5_0-1752238678391.png

 

1st page Input Values should Update into Recipient schema. But its not working with below script.

SantoshKa5_3-1752239182199.png

 

// Update RCP Data

var id = ctx.recipient.@id;
var ID_PARTENAIRE = ctx.vars.bp_id;
var Business = ctx.vars.bp_Business;
var Entity = ctx.vars.bp_Entity;

var currentDate = formatDate(new Date(), "%4Y/%2M/%2D %02H:%02N:%02S");
xtk.session.Write(<recipient xtkschema="nms:recipient" operation="_update" _key="@id,@ID_PARTENAIRE,@Business,@Entity" firstName={ctx.vars.updfirstName} lastName={ctx.vars.updlastName} email={ctx.vars.updemail} lastModified={currentDate} />);

 

Getting below Error once submit the Button in Form, stating Unable to find the Key values for element Recipient.

SantoshKa5_2-1752238865378.png

 

Note: we have Extended the nms: recipient schema and added custom columns as Keys. I am using those for Update or Insert Operations.

Other hand, same script inserting new record when I am trying without Key argument.

 

The Storage activity not helping to update, pre-loaded columns. 

 

Can anyone help me solve this error.

 

Thank you.

 

 

 

Topics

Topics help categorize Community content and increase your ability to discover relevant content.

1 Accepted Solution

Avatar

Correct answer by
Community Advisor

Hello @SantoshKa5 

 

When performing an update operation using xtk.session.Write, you should specify the attributes that correspond to the keys in the XML structure. This ensures that the update operation correctly identifies the recipient record you want to modify.

Here’s how you can modify your xtk.session.Write call to include the attributes explicitly:

// Update RCP Data
var id = ctx.recipient.@id;
var ID_PARTENAIRE = ctx.vars.bp_id;
var Business = ctx.vars.bp_Business;
var Entity = ctx.vars.bp_Entity;

var currentDate = formatDate(new Date(), "%4Y/%2M/%2D %02H:%02N:%02S");

xtk.session.Write(
    <recipient xtkschema="nms:recipient" operation="_update" 
        _key="@id,@ID_PARTENAIRE,@Business,@Entity" 
        id={id} 
        ID_PARTENAIRE={ID_PARTENAIRE} 
        Business={Business} 
        Entity={Entity} 
        firstName={ctx.vars.updfirstName} 
        lastName={ctx.vars.updlastName} 
        email={ctx.vars.updemail} 
        lastModified={currentDate} />
);

 

Br,

View solution in original post

5 Replies

Avatar

Level 2

// Update RCP Data

var id = ctx.recipient.@id;
var ID_PARTENAIRE = ctx.vars.bp_id;
var Business = ctx.vars.bp_Business;
var Entity = ctx.vars.bp_Entity;

var currentDate = formatDate(new Date(), "%4Y/%2M/%2D %02H:%02N:%02S");

xtk.session.Write(<recipient xtkschema="nms:recipient" _operation="insertOrUpdate" _key="@id,@ID_PARTENAIRE,@Business,@Entity" firstName={ctx.vars.updfirstName} lastName={ctx.vars.updlastName} email={ctx.vars.updemail} lastModified={currentDate} />);

 

Avatar

Level 2
Level 2

Hi @SantoshKa5 

Can you please check whether the ctx.vars.updfirstName and  other ctx variable have the value .

Eg:logInfo("Value of updfirstName: " + ctx.vars.updfirstName);

And Pass them like below 

var firstname = ctx.vars.updfirstName;

And in the xtk.write method,

Change into firstName={fristname} do the same for lastname and email

Avatar

Level 2
Level 2

Hi @SantoshKa5 ,

Please try this below code and let me know whether its works

var xml = '<recipient xtkschema="nms:recipient" _operation="Update" _key="@id,@ID_PARTENAIRE,@Business,@Entity" ' +
'firstName="' + ctx.vars.updfirstName + '" ' +
'lastName="' + ctx.vars.updlastName + '" ' +
'email="' + ctx.vars.updemail + '" ' +
'lastModified="' + currentDate + '"' +

'/>';

xtk.session.Write(xml);

Avatar

Correct answer by
Community Advisor

Hello @SantoshKa5 

 

When performing an update operation using xtk.session.Write, you should specify the attributes that correspond to the keys in the XML structure. This ensures that the update operation correctly identifies the recipient record you want to modify.

Here’s how you can modify your xtk.session.Write call to include the attributes explicitly:

// Update RCP Data
var id = ctx.recipient.@id;
var ID_PARTENAIRE = ctx.vars.bp_id;
var Business = ctx.vars.bp_Business;
var Entity = ctx.vars.bp_Entity;

var currentDate = formatDate(new Date(), "%4Y/%2M/%2D %02H:%02N:%02S");

xtk.session.Write(
    <recipient xtkschema="nms:recipient" operation="_update" 
        _key="@id,@ID_PARTENAIRE,@Business,@Entity" 
        id={id} 
        ID_PARTENAIRE={ID_PARTENAIRE} 
        Business={Business} 
        Entity={Entity} 
        firstName={ctx.vars.updfirstName} 
        lastName={ctx.vars.updlastName} 
        email={ctx.vars.updemail} 
        lastModified={currentDate} />
);

 

Br,

Avatar

Level 2

Hi @Amine_Abedour ,

Thanks Amine. Its worked for me. I forgot to include those Keys.