with Multirow variable set submit catalog item, need to create one new story record with description
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-19-2023 09:35 PM
Hi Developers,
I have a catalog item that include multi row variable set(include 10 variables), While submitting catalog item i need to create a new Story record in the record description field need to update all the Multi row variables data and variable labels also need to populate.
EX: if the variable label is Type in description field need populate: Type: XYZ.
Can any one help me on this.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-19-2023 10:15 PM
Hello @praveen47
Can you please provide little bit more information ?
ServiceNow Developer
I know one thing, and that is that I know nothing.
- Socrates
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-19-2023 10:48 PM
HI @Vishal Birajdar ,
I have created one new catalog item " Servicenow Basic request". This Catalog item is used for any user wants to create new catalog item then submit this request. In this catalog item i have added one Multi row variable set it includes 11 varaibles. Here the Variables.
Type | Mandatory (Yes/No) | Read only (Yes/No) | Hidden (Yes/No) . | Condition Descriptions | Question | Choices | Default Value . | Look Up Table | Help Text Help Information | Tooltip | Example Text | Notes |
If the user submits this request it going to manager approval then need create a Story record (rm_story table). For this i have added approval in workflow and once it is approved i have added Runscript for creating Story record. I have written the below script:
var userGr = new GlideRecord("rm_story");
userGr.initialize();
userGr.description = current.variables.type_2.getLabel().getDisplayValue() + ' ' + current.variables.type_2.getDisplayValue();
userGr.insert();
I have tried for One variable it is showing "undefined" in Description field.
I need in Story form description field should auto populate data from Variables data. If the User enter more then One row need show in new Line.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-19-2023 11:08 PM - edited 02-19-2023 11:09 PM
You need to loop through the MRVS to get the Values of each row in your workflow run script
var mrvsDetails = current.variables.<Your MRVS Name>;
//gs.log("JSON Object = ") + mrvsDetails;
var parser = JSON.parse(mrvsDetails);
/*GlideRecord on 'Story Table' & loop through each record for MRVS*/
for (var i = 0; i < parser.length; i++) {
var grStory = new GlideRecord("<Story_Table_Name>");
grStory.initialize()
grStory.description = parser[i].<variable_name1 from MRVS> + parser[i].<variable_name2 from MRVS> ;
grStory.insert();
}
Hope this works for you...!!
ServiceNow Developer
I know one thing, and that is that I know nothing.
- Socrates
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-19-2023 11:39 PM
Hi @Vishal Birajdar ,
Thanks for your quick reply.
I have tried to add this script, It is getting backend values (like i added type variable data that is choice type field. in story description it is giving value of the choice.), And also i need show variable label also before the data.