How to create a record in custom table with the service catalog variables and workflow
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-04-2023 10:06 AM - edited 03-04-2023 10:14 AM
I have a service catalog item which contains list fields. In the catalog item there are two variables of type list collector they are Application and Role.
My requirement is to create create a new record in User Application table(custom table) when the catalog item was submitted. If I select two applications and two roles 4 records should be created in the user application table.
Can anyone suggest script that I have to use in workflow.
Thank you.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-04-2023 10:56 AM - edited 03-04-2023 11:10 AM
@Community Alums in workflow add run script activity and write this code
var use = current.variables.requested_for;
var app = current.variables.application;
var applen = app.join(',');
var rol = current.variables.roles;
var rollen = rol.join(',');
for(var i=0; i>applen.length;i++){
var cs = new GlideRecord("youcustomtablename");
cs.initialize();
cs.user = use;
cs.application=applen[i];
cs.insert();
}
for(var k=0; k>rolelen.length;k++){
var cs1 = new GlideRecord("youcustomtablename");
cs1.initialize();
cs1.user = use;
cs1.roles=rollen[k];
cs1.insert();
}
Bharath Chintala
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-05-2023 06:59 AM - edited 03-05-2023 06:59 AM
It is not working @BharathChintala
I have reference fields in the custom table. My requirement is to populate the list collector values of catalog item to reference field in custom table.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-05-2023 10:00 AM
@Community Alums I have sent script based on screen shot u have attached. Please check backend names of variables and fields
Bharath Chintala