- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎02-01-2024 03:58 PM
We have a specific offering on the Service Portal for our business applications for reporting incidents. For one of the business applications we would like to collect a few extra fields and have them in the incident when it gets created. I can have the variables added to all of the incidents created by the record producer but when I try to qualify it I can't seem to get the IF condition to be true. We are collecting the CI as a variable and mapping that to the CI field on the Incident. The first two conditions work well and if I remove the If concident the varibales show on any incident created by the record producer.
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎02-05-2024 02:34 PM
Hey, yeah, you want to make sure you remove the semi-colon (if you keep it then you'd see that the work notes appears on all incidents).
If it can't recognize the Config Item value, it most likely isn't the value that you think it is, that's where logging it would help to see its actual value. If the variable is a reference field, then you'd be picking up it's sys_id rather than it's display value. To get it's display value, you can try with .getDisplayValue():
current.contact_type = 'self-service';
current.u_location = producer.caller_id.location;
var ConfigItem = producer.cmdb_ci.getDisplayValue(); // get the display value if cmdb_ci is a variable of type reference
if (ConfigItem == 'Yardi - Tenant Portal') // lower `i` in if, removed semi-colon `;`
current.work_notes = "Tcode: " + producer.tcode;
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎02-01-2024 04:52 PM
Your syntax isn't right:
- You should be using a lowercase 'i' in your if statement
- You have a semi-colon after your if-statement. JavaScript uses blocks { } to denote what's part of the if-statement (which can be optionally left off if you have one statement following the if.
current.contact_type = 'self-service';
current.u_location = producer.caller_id.location;
var ConfigItem = producer.cmdb_ci;
if (ConfigItem == 'Yardi - Tenant Portal') // lower `i` in if, removed semi-colon `;`
current.work_notes = "Tcode: " + producer.tcodeIf this still doesn't work, log (using something like gs.info()) what the value is of ConfigItem and confirm that it is what you think it is (Yardi - Tenant Portal)
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎02-05-2024 08:50 AM
Thanks. changing the case helped but with the semi-colon it displays the work note on all the incidents. Can quite seem to get it to recognize the Config Item value. tried both current and producer. Would I need some like a command to get value for the variable?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎02-05-2024 02:34 PM
Hey, yeah, you want to make sure you remove the semi-colon (if you keep it then you'd see that the work notes appears on all incidents).
If it can't recognize the Config Item value, it most likely isn't the value that you think it is, that's where logging it would help to see its actual value. If the variable is a reference field, then you'd be picking up it's sys_id rather than it's display value. To get it's display value, you can try with .getDisplayValue():
current.contact_type = 'self-service';
current.u_location = producer.caller_id.location;
var ConfigItem = producer.cmdb_ci.getDisplayValue(); // get the display value if cmdb_ci is a variable of type reference
if (ConfigItem == 'Yardi - Tenant Portal') // lower `i` in if, removed semi-colon `;`
current.work_notes = "Tcode: " + producer.tcode;
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎02-01-2024 05:54 PM
If (ConfigItem == 'Yardi - Tenant Portal');
change to
if (ConfigItem == 'Yardi - Tenant Portal');// java script is case sensitive, if and If are different use lowercase letter
Harish
