How to add Requested item name field in Catalog Item Approval page?

ramireddy
Mega Guru

Hi,

I wants to show "Name of the item requested" field also in Approval page. Currently it's showing only "Request" number. But I wants to display the items as well that are requested as part of this request in Approval page. For example, If a "Computer" is requested as part of a REQ0001, I wants to show the name of the item "Computer" as well, while approving.

Screen Shot 2016-01-08 at 3.13.11 pm.png

I know, we can add fields by Personalizing form layout. However, I am not able to find the "fields", where request items can be displayed.

Screen Shot 2016-01-08 at 3.14.51 pm.png

1 ACCEPTED SOLUTION

divyalakshmi
Tera Guru

Hi Ram,



I have done a small change in the above code. Please use the below code


test();


function test()


{


var itemname='';


//gs.log("Approval For"+current.sysapproval);


var gr=new GlideRecord("sc_req_item");


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


gr.query();


while(gr.next())


  {


  itemname+=(','+gr.cat_item);


// gs.log("itemname"+itemname);


  }



current.u_item_name=itemname;


  //gs.log("in"+current.u_item_name);


current.update();


}



This works fine if the new filed u_item_name is of type List. When you place order for multiple items this will return multiple item's name in the Approval form.


View solution in original post

5 REPLIES 5

divyalakshmi
Tera Guru

Hi Ram,



Approval for field is referencing Task table so it is not possible to get the requested item name directly. However you can see the Requested item number and its detail when you configure the form layout by moving Approval summarizer from left slush bucket to right slush bucket.



The other way is to glide the requested item table with the request number(Approval for) and get the item name in some new field in the Approval form.



Let me know if this solves your problem.


Hi Divya Lakshmi,



Approval summarizer is already displaying in the form. But i need this value for a certain business logic. So, I wants to display as a separate field.



Can you give me more details about the second approach, "glide the requested item table with the request number(Approval for) and get the item name in some new field in the Approval form.". How to implement this?


divyalakshmi
Tera Guru

Hi Ram,



You need to create a new field of type list or reference in Approval form, the field should reference to catalog item table.



Write a before insert Business Rule on Approval Table. Follow the below code and it is displaying the item name in Approval form


Here u_item_name is the new field of List type.



test();


function test()


{


var itemname="";


//gs.log("Approval For"+current.sysapproval);


var gr=new GlideRecord("sc_req_item");


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


gr.query();


while(gr.next())


  {


itemname+=gr.cat_item;


// gs.log("itemname"+itemname);


  }


current.u_item_name=itemname;


//   gs.log("in"+current.u_item_name);


current.update();


}



Let me know if this works for you.


divyalakshmi
Tera Guru

Hi Ram,



I have done a small change in the above code. Please use the below code


test();


function test()


{


var itemname='';


//gs.log("Approval For"+current.sysapproval);


var gr=new GlideRecord("sc_req_item");


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


gr.query();


while(gr.next())


  {


  itemname+=(','+gr.cat_item);


// gs.log("itemname"+itemname);


  }



current.u_item_name=itemname;


  //gs.log("in"+current.u_item_name);


current.update();


}



This works fine if the new filed u_item_name is of type List. When you place order for multiple items this will return multiple item's name in the Approval form.