sc_req_item & request_item

ashleygreens
Giga Contributor

Hi Folks,

I have a question regarding Service catalog. I am trying to understand the difference between

sc_req_item     & request _item.   Can someone explain me the difference between the two.

Thanks,

Ashley

1 ACCEPTED SOLUTION

Hi Ashley,



The request_item is a column name in sc_item_option_mtom table which takes sys_id of the RITMs. That will help to filter out the GlideRecord of sc_item_option_mtom table to extract the data of a particular related records.


View solution in original post

14 REPLIES 14

Please check the thread below.



Variable Ownership table


Hi Ashley,



The request_item is a column name in sc_item_option_mtom table which takes sys_id of the RITMs. That will help to filter out the GlideRecord of sc_item_option_mtom table to extract the data of a particular related records.


Shishir, i appreciate your effort, all this you gave is greek and latin to me !! Hahah, i am pretty new to this technology and i am trying by best to understand each concept. It will be great if you could explain bit more for me.



Thanks XXX


Let me try to explain if I can,



var task = new GlideRecord('sc_task'); // GlideRecord fetches all the record of table (ex. sc_task)


//task.addQuery('assignment_group', 'd77c144f2b47308407ba65dee8da156d'); // when you do add query that means basically you are using where clause to provide the condition on you what basis you want to fetch the record.


//task.addQuery('state', '!=', 3);


//task.addQuery('state', '!=', 4);


task.query(); // when you do query(), that means you are executing your GlideRecord provided all the conditions in addQuery


while (task.next()) { //next() will traverse all the found record, when you use while that means you are looping all the found record and when you use if then that means you are just validating if there were found and then proceed


      var mtom = new GlideRecord('sc_item_option_mtom'); // GlideRecord fetches all the record of table (ex. sc_task)


      mtom.addQuery('request_item', task.request_item);   (**** Why is he using request_item here ) //The request_item is a column name in sc_item_option_mtom table which takes sys_id of the RITMs. That will help to filter out the GlideRecord of sc_item_option_mtom table to extract the data of a particular related records.


      mtom.query();


      while (mtom.next()) {


              gs.log('Task# ' + task.number + '/' + task.request_item.getDisplayValue() + '/Question:'+mtom.sc_item_option.item_option_new.question_text + '/Answer:'+mtom.sc_item_option.value);


      }


}


sc_item_option_mtom:   is a Variable Ownership table, you can access all variable related to any request item, please check the example below.


Querying Service Catalog Tables

You cannot directly query the variables of the Service Catalog Request Item table [sc_req_item]. Instead, query the Variable Ownership table, [sc_item_option_mtom], by adding two queries, one for the variable name and another for the value. The query returns the many-to-many relationship, which you can dot-walk to the requested item. The following example finds the request items that have the variable item_namewith a value of item_value and displays the request item numbers:


var gr = new GlideRecord('sc_item_option_mtom'); 
gr
.addQuery('sc_item_option.item_option_new.name','item_name');
gr
.addQuery('sc_item_option.value','item_value');
gr
.query();  
while(gr.next())
{ gs.addInfoMessage(gr.request_item.number); }


Reference: GlideRecord query examples


Shishir Srivastava Perfect explaination. Impressed.



With regards to "sc_item_option_mtom" can you please let me know more about the code below. Tried the above code but it didnt go well.