Help setting default value on reference field

Gemma4
Mega Sage

Hi,

Hoping this is a quick question for everyone that I'm just not aware of. I added configuration item as a reference field on my order guide and would like to set the default value. I've tried setting it in default value but it will not save. In addition, I've tried adding it under  Type specifications Name=ProjectManagement. See attached. In addition, when I try it on the portal, the value of Project Management is visible but it is not set as a default. 

We would like to set this as a default and make it hidden to ensure it is always set correctly to help us with setting some default values on business rules. 

Thanks so much for any feedback you can provide!

 

 

1 ACCEPTED SOLUTION

Sohail Khilji
Kilo Patron
Kilo Patron

Dear @Gemma4 ,

 

You can do it in 2 ways:

1. you can use the sys_id value of the referecing record in default value field. (Recommended)

 

[OR]

 

2. Create a catalog client script along with g_scratchpad varaible.

 

I hope this help...

 

 

 

 


ā˜‘ļø Please mark responses as HELPFUL or ACCEPT SOLUTION to assist future users in finding the right solution....

LinkedIn - Lets Connect

View solution in original post

6 REPLIES 6

Ravi Chandra_K
Kilo Patron
Kilo Patron

Hello @Gemma4 

Are you getting any error while saving the default value?

Kind Regards,

Ravi Chandra.

Hello,

The good news is I have everything almost working but I am having trouble with my business rule script. Here is a summary of my progress and the script details. 

I created a configuration item called ProjectManagement

I created a variable called configuration item and set the default value to the sys id

This part enabled the configuration to be added(hidden)on the catalog item

I then created a business rule to copy the variable configuration to the Request field called configuration item.

Then I created a business rule to set the request state to New if the configuration item is Project management. This last  part isn't working and changing the state. I set the table to Request, when to run is after, filter confidition is Configuration item changes to ProjectManagement. 

 

Anyone have any ideas why? 

 

 

//(function executeRule(current, previous /*null when async*/) {
 
// Add your code here
//var gr= new GlideRecord("sc_req_item");
//gr.addQuery('request', current.sys_id);
////gr.addQuery('cat_item','52a1fd631b47215053545243604bcb35');
// //gr.addQuery('cat_item','7c3fbb0b97c321102ab77d100153af5b'); project catalog
// gr.addQuery('cmdb_ci','98ebee741ba4711053545243604bcb74'); //project cmdb value
gr.query();
//if(gr.next()){
//current.request_state= 'New';
//// grRequestItems.state = 10; // "Stopped" state change if required
// }
 
 
//})(current, previous);
 
 
 
(function executeRule(current, previous /*null when async*/) {
 
var req = new GlideRcord('sc_request');
req.addQuery('sys_id', current.request);
req.query();
while (req.next()) {
req.request_state = 'New';
req.update();
}
})(current, previous);

@Gemma4 ,

 

I guess we were able to fix your previous issue which you had no response, This seems to be a new Thread you opened... Can you consider marking the solution helpful/correct if it helped. 

 

By the way, you can manage all this in your request workflow Script which is recommended, not sure why are you trying via business rule ? may I know the business need on this ?

 

i hope this helps...

 


ā˜‘ļø Please mark responses as HELPFUL or ACCEPT SOLUTION to assist future users in finding the right solution....

LinkedIn - Lets Connect

Correct, thanks for the help! Appreciate your time.