Expand my Community achievements bar.

Adobe Campaign User Groups are live now. Join our Adobe Campaign User Groups and connect with your local leaders!
SOLVED

How to pass a reference to variable in Update query

Avatar

Level 2

Hi,

 

I have to insert/update data to Campaign classic DB from a JS activity. I receive the info in a webservice call, so i read the date and loop and have to pass the details in an update query. But the query is only accepting values not a reference to variable which I read from the call. please advice how an I pass a reference to var?

 

I have the below script,

 

workEmail is the variable with value I read from the webservice call data.

 

var updateEmp = <recipient xtkschema="nms:recipient"
operation="_update" _key="@email"

email= workEmail
futRetNot="true" />

xtk.session.Write(updateEmp);

 

I get this error,

 

 js JST-310000 Error while compiling script 'tWKF945/js' line 79: invalid XML attribute value (line=' email= workEmail' token='workEmail').

 

How can I pass the workEmail?

 

Thanks,

Sirisha

 

 

1 Accepted Solution

Avatar

Correct answer by
Community Advisor

Hello @sirikambampati 

 

You can pass it like this.

email= {workEmail}

 


     Manoj
     Find me on LinkedIn

View solution in original post

12 Replies

Avatar

Correct answer by
Community Advisor

Hello @sirikambampati 

 

You can pass it like this.

email= {workEmail}

 


     Manoj
     Find me on LinkedIn

Avatar

Level 2

Hi @_Manoj_Kumar_ 

 

In my Campaign instance, I have recipient folder in two different locations,

1) under Profiles & Targets

2) Customized for us, under Business Units.

 

When I try to insert data it is writing into the schema under Profiles & Targets, which is 1) location. But we want it to be inserted in the 2) location.

 

Do I have to include a folder_id in the insert xml query?

Please advice.

 

Thanks!

 

How can I insert data in the different location, do I have to mention folder _id in the insert?

 

Avatar

Community Advisor

Hello @sirikambampati, Yes, you are correct. You will have to add folder-id=FOLDER_ID in the query xml.

 

 


     Manoj
     Find me on LinkedIn

Avatar

Level 2

@_Manoj_Kumar_ ,Is this the way?

 

var myXML = <recipient xtkschema="nms:recipient" folder-id=31114 _key="@folder-id"

firstName= {fname}
lastName={lname}
email = {em}
gmin ={gm} />

xtk.session.Write(myXML);

Avatar

Community Advisor

Hello @sirikambampati 

You are missing the _operation attribute. If you are trying to update the recipient, then make sure the _key="@email" is an email or something unique to that recipient.

 

The code will look like this if you are trying to insert or update the recipient in a folder with id 31114. The reconciliation key used for this update is email.

var myXML = <recipient xtkschema="nms:recipient" folder-id=31114 _key="@email"
_operation="insertOrUpdate"
firstName= {fname}
lastName={lname}
email = {em}
gmin ={gm} />
xtk.session.Write(myXML);

 


     Manoj
     Find me on LinkedIn

Avatar

Level 2

IS there no need of mentioning @folder-id in the _key along with @email?

Avatar

Community Advisor

@sirikambampati Yes, No need to mention the folder id in the key


     Manoj
     Find me on LinkedIn

Avatar

Level 2

@_Manoj_Kumar_ Thank you, much appreciated.

 

I am actually reading the data from a webservice call and have to send notification/delivery email to the email id which dynamically comes from the API.

 

How can I pass this into a delivery which I have to send through the JS activity.?

 

I have a template for delivery with content, I have to use that template to send a delivery with the email_id which comes from the webservice call and also first and last name??

Avatar

Community Advisor

Hello @sirikambampati 

 

You can use the QueueNotification method mentioned over here:

QueueNotification (adobe.com)

 

Here is a simple code:

nms.delivery.QueueNotification("confirmation",
<delivery>
<targets>
  <deliveryTarget>
    <targetPart type='query' exclusion='false' ignoreDeleteStatus='false'>
      <where>
        <condition expr={'@email ='+ EMAIL}/>
      </where>
    </targetPart>
  </deliveryTarget>
</targets>
</delivery>)

  

Warning: this API is not built to manage large volumes of data or work in real-time. It is developed to process a maximum of several calls per minute. SubmitNotification blocks the thread during delivery analysis. This may take a few seconds. The "target" parameter specifies the delivery target. It will override a target specified in the template. To deliver to a target in the database the target element will use the following syntax:


     Manoj
     Find me on LinkedIn

Avatar

Level 2

Hi,

 

Here is my code:

 

var email = "Test@gm.com";

nms.delivery.QueueNotification('rNotification',
<delivery>
<targets>
<deliveryTarget>
<targetPart type='query' exclusion='false' ignoreDeleteStatus='false'>
<where>
<condition expr={'@email ='+ email}/>
</where>
</targetPart>
</deliveryTarget>
</targets>
</delivery>)

 

 

I get this error:

 

XSV-350020 URL not provided. Failed to find an instance.

Avatar

Level 2
var myXML = <recipient xtkschema="nms:recipient" folder-id=31114 _key="@email"
_operation="insertOrUpdate"
firstName= {fname}
lastName={lname}
email = {em}
gmin ={gm} />
xtk.session.Write(myXML);

Hi,

 

The above code is not writing to the mentioned folder, infact I dont see the data written to any recipient schema now?