Highlighted
Absent Member.. Absent Member..
Absent Member..
587 views

Item.description field from svcatitem to incidents

Hi Experts,

 

We have a requirement of copying the item.description value from the svccatitem table to the interaction record in a new field , Please suggest how to acheive it , since the catalog item name needs to be captured in the email notification.

 

Have tried the folloewing, but doesnt work.

sl- catalog add
 
function newparamadd(record){
 
var myCartItem = new SCFile("svcCartItem");
var rc = myCartItem.doSelect("cartItemId=\"" + record[0] + "\"");
 
if(rc == RC_SUCCESS){
 
var MyVar = system.vars.$cart_item;
 
myCartItem.item_description = MyVar;
 
myCartItem.doUpdate();
}
}
 
triggers:
 
incidents(after add)
system.library.Catalogadd.newparamadd(record);
print("Cart ID");
 
Please suggest.
0 Likes
8 Replies
Highlighted
Outstanding Contributor.. Outstanding Contributor..
Outstanding Contributor..

Re: Item.description field from svcatitem to incidents

hi @Madhu84

ur code should like bellow. 

 

function newparamadd(number){
var myCartItem = new SCFile("svcCartItem");
if (myCartItem.doSelect("cartItemId=\"" + number + "\"")==RC_SUCCESS){
return myCartItem.item_description;
} else return "";   
}

trigger type = before update

trigger code

record.YourNewFieldName = lib.Catalogadd.newparamadd(record.incident_id);

HTH.  

 

Highlighted
Absent Member.. Absent Member..
Absent Member..

Re: Item.description field from svcatitem to incidents

Hi ,

 

I tried 

 

function newparamadd(number){
var myCartItem = new SCFile("svcCartItem");
if (myCartItem.doSelect("cartItemId=\"" + number + "\"")==RC_SUCCESS){
return myCartItem.item_description;
} else return "";
}

 

triggers:

 

record.cart_item = lib.Catalogadd.newparamadd(record.incident_id);

 

for testing i tried with after add and before update , still no value for cart.item field

0 Likes
Highlighted
Micro Focus Expert
Micro Focus Expert

Re: Item.description field from svcatitem to incidents

After Add will not work of course because the record has already been added to the database.  Before update should work.

For testing I suggest you change the SL to

else return "No Item Found";

which would at least let you know that your trigger was being processed and that the issue was the select not working.

Highlighted
Absent Member.. Absent Member..
Absent Member..

Re: Item.description field from svcatitem to incidents

Hi,

 

After modifying the script with else "No cart item" i get this value displayed in the email.

 

So my email notification has the field for cart item as " No cart Item" instead of the original cart item name from SRc

0 Likes
Highlighted
Micro Focus Expert
Micro Focus Expert

Re: Item.description field from svcatitem to incidents

Try this

record.cart_item = lib.Catalogadd.newparamadd(record.cartId);

The svcCartItem associated with the Interaction is in the cartId field.

0 Likes
Highlighted
Absent Member.. Absent Member..
Absent Member..

Re: Item.description field from svcatitem to incidents

Hi ,

 

On trying this i get irrelevant values in cart_item field say i raise a request for password reset in the mail instead of password reset i get some other cart description value, so i feel it is not taking the relevant item.description for that record.

0 Likes
Highlighted
Micro Focus Expert
Micro Focus Expert

Re: Item.description field from svcatitem to incidents

Sorry about that I failed to mention that you also need to change your doSelect to

if (myCartItem.doSelect("cartId=\"" + number + "\"")==RC_SUCCESS){

 

cartId in interaction maps to cartId in svcCartItem

note that there may be multiple items in the cart so this will get you the first item only.

0 Likes
Highlighted
Absent Member.. Absent Member..
Absent Member..

Re: Item.description field from svcatitem to incidents

Hi still taking random value during the first email trigger , however the other emails after interaction is raised has perfect value in cart.item only the intiial email trigger has issue , when checking RAD debugger after interaction is created the value for cart.item has right value , the issue is only with first email sent out.

 

sl-function newparamadd(number){
var myCartItem = new SCFile("svcCartItem");
if (myCartItem.doSelect("cartId=\"" + number + "\"")==RC_SUCCESS){
return myCartItem.item_description;
} else return "No Item";
}

 

trigger : before update

record.cart_item = lib.Catalogadd.newparamadd(record.cartId);

0 Likes
The opinions expressed above are the personal opinions of the authors, not of Micro Focus. By using this site, you accept the Terms of Use and Rules of Participation. Certain versions of content ("Material") accessible here may contain branding from Hewlett-Packard Company (now HP Inc.) and Hewlett Packard Enterprise Company. As of September 1, 2017, the Material is now offered by Micro Focus, a separately owned and operated company. Any reference to the HP and Hewlett Packard Enterprise/HPE marks is historical in nature, and the HP and Hewlett Packard Enterprise/HPE marks are the property of their respective owners.