Include catalog item's properties in Request table notification email

SC10
Kilo Guru

I've created a new 'translated html' field on the Catalog Item form, similar to that of "Description", to add in some more information to my catalog items.

I'd like to use this additional information in the emails that send out when the catalog item's Request (sc_request table) is closed.

Can I dot walk to the properties of my Catalog Item? Can I pull the display value of my new 'translated html' field even? I tried doing a mail script to pull the data of my new "testinfo" field, but it comes back as undefined:

<mail_script>

    var gr = new GlideRecord("sc_req_item");

    gr.addQuery("request", current.sys_id);

    gr.query();

    while(gr.next()) {

    template.print(gr.testinfo.getDisplayValue());

  }

</mail_script>

1 ACCEPTED SOLUTION

Good day,



I was able to get this working after using the following code:



var gr = new GlideRecord("sc_req_item");


    gr.addQuery("request", current.sys_id);


    gr.query();


    while(gr.next()) {


    template.print(gr.cat_item.u_test_info.getDisplayValue());


  }



This works as the email notification is running off of the Request table.



Thank you for everyone's time, especially Venkat who assisted me along with this day after day.


View solution in original post

32 REPLIES 32

Srinivas Balusu
Kilo Guru

Check if other values are coming from the table passing the sys_id.



Then try to get the value directly. If you are using similar to this, the message should be translated automatically. Let me know if I am wrong.


find_real_file.png


ccajohnson
Kilo Sage

In order for us to troubleshoot effectively, a few clarifications are needed:


1. Is this testinfo field on the Requested Item [sc_req_item] table, or the Catalog Item [sc_cat_item] table?


2. Have you tried background scripts to make sure you are pulling back the information you need?



Let me know so I can narrow my answer accordingly.


1. It is on the sc_cat_item table, as it's a field within my catalog item


2. I have not tried background scripts as my mail script is already pulling data from the request, and I am trying to adapt it in a similar fashion for my new field.


This now makes a bit more sense. In order to use the background scripts:


1.   Elevate your privileges to security_admin.


2.   Type: Scripts - Background to show the module.



From here you can type into the window and test things out. I would capture the sys_id of the request record in question, then use the following as a starting point for your script troubleshooting:



var current = new GlideRecord('sc_request');


current.get('SYSIDSTRINGGOESHERE');



var itmObj = new GlideRecord("sc_req_item");


itmObj.addQuery("request", current.sys_id);


itmObj.query();


while(itmObj.next()) {


      gs.print(itmObj.cat_item.testinfo);


}



Please note that you want to replace the sys_id you capture in the current.get method. Also, since you indicated this is in the catalog item record and not the requested item record, you need to dot-walk to the field in question. Finally, I do not think that the getDisplayValue() method is needed since you will get the raw html value which is what you want in your notification anyway.



Let me know if you need further assistance,