- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎09-13-2023 01:39 AM
Hello there,
I have a Service Portal Incident form (Record Producer), with several fields (variables).
I write this fields through a script, to the Incident "Description"- field.
Now I want to NOT include the fields that were NOT filled in in the Service Portal Incident form.
Is it possible to do that easy by an extra script addition and how?
Thanks very much and all best!
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎09-13-2023 11:22 AM
If the variables are defined in the Record Producer within a single row variable set, there is no difference in the syntax than if they were not in a variable set. If they are in a multi-row variable set, that's a different story. Assuming your question1 yes/no lines are working to dump the correct variables into the description field, you would stick with the same syntax to not print the blank variables. There might be a better way to do this, but something like:
var cn = '';
var fieldb = '';
var fieldc = '';
var fieldd = '';
var fielde = '';
var field1 = '';
var field2 = '';
var field3 = '';
var field4 = '';
if (producer.computername.getDisplayValue() != '') {
cn = 'Computername: ' + producer.computername.getDisplayValue() + "\n";
}
if (producer.fieldb != '') {
fieldb = 'Field B: ' + producer.fieldb + "\n";
}
// create an if block for each of the other variables ...
var description_set_1 = cn + fieldb + fieldc + fieldd + fielde;
var description_set_2 = cn + field1 + field2 + field3 + field4;
if (producer.question1 == 'yes') {
current.description = description_set_1;
} else {
current.description = description_set_2;
}
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎09-14-2023 08:17 AM
I tried this script now, but sadly it doesn't write anyting down in the Description- field of the Incident.
I have no idea what it could be. Everything seems to be OK.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎09-14-2023 08:43 AM
It works, thanks! The problem I had with this script was that I put the "VAR sets" above in the script, instead of below the "}" somewhere further down the script.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎09-14-2023 10:44 AM
Good to hear, and you are welcome!