- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎04-30-2015 01:44 AM
When I create a new asset in "alm_hardware" table, a ci also get created in the "cmdb_ci table. I have create a before business rule on cmdb_ci table that will rename the ci name in the cmdb_ci table with serial number and also whatever the stockroom name was when creating the asset. My script is not getting the stockroom name because it looks like the ci get created first before the asset get created. Any idea how can I capture the stockroom name correctly?
Here is my business rule
var sn = current.getDisplayValue('serial_number');
var stock = "";
var pref;
var loc = new GlideRecord ("alm_hardware");
loc.addQuery(sn);
loc.query();
if ( loc.next() )
{
stock = loc.stockroom.name;
}
if ( stock == "HQ" )
{
$pref = "SJC";
}
else if ( stock == "Amsterdam" )
{
$pref = "AMS";
}
else if ( stock == "Plano" )
{
$pref = "DFW";
}
else if ( stock == "Singapore" )
{
$pref = "SIN";
}
else if ( stock == "Tokyo" )
{
$pref = "NRT";
}
if ( current.manufacturer.getDisplayValue() == "Apple" )
{
//current.ci.setDisplayValue(sn);
var leight = sn.substr(sn.length - 8);
current.name = $pref + "MAC" + leight;
}
else if ( current.manufacturer.getDisplayValue() == "Dell" )
{
current.name = pref + "WIN" + sn;
}
//gs.addInfoMessage(sn + "---" + current.manufacturer.getDisplayValue() + "---" + stock);
Solved! Go to Solution.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎04-30-2015 06:26 PM
For reference field you can restrict it with the help of reference qualifier. Please refer the sample example 4.3.2.2 in the below wiki link.
http://wiki.servicenow.com/index.php?title=Reference_Qualifiers

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎04-30-2015 06:26 PM
For reference field you can restrict it with the help of reference qualifier. Please refer the sample example 4.3.2.2 in the below wiki link.
http://wiki.servicenow.com/index.php?title=Reference_Qualifiers