Inserting empty in custom table(Multi row variable set)

Sneha39
Mega Guru

Created MRVS on catalog item and inserting these variable values into the custom table but its adding empty value in the custom table.

 

using below script in task activity of workflow ( As i want task to be created and in the same time variables values to be submitted in custom table as well)

(function() {

        var rowsInt = current.variables.server_request.getRowCount();

        for (var i = 0; i < rowsInt; i++) {

           var grTask = new GlideRecord('u_customtbl);

            grTask.initialize();

            grTask.u_usercerts = current.variables.user_certs;

            grTask.insert();

        }

 

})();

find_real_file.png

 

 

26 REPLIES 26

Hitoshi Ozawa
Giga Sage
Giga Sage

mrvs are saved as JSON.

var mrvs = JSON.parse(current.variables['server_request']);  // 'server_request' is name of mrvs
for (var i=0; i<mrvs.length; i++) {
  var grTask = new GlideRecord('u_customtbl);
  grTask.initialize();
  grTask.u_usercerts = mrvs[i].user_certs;
  grTask.insert();
}

getting below error.

find_real_file.png

How about the code below.

var mrvs = JSON.parse(current.variables.server_request);  // 'server_request' is name of mrvs
for (var i=0; i<mrvs.length; i++) {
  var grTask = new GlideRecord('u_customtbl);
  grTask.initialize();
  grTask.u_usercerts = mrvs[i].user_certs;
  grTask.insert();
}

same error not working

JohnnySnow
Kilo Sage

Hi Sneha,

There is a missing single quotes here, please include that as well, I'm not sure if that is handled. 

  var grTask = new GlideRecord('u_customtbl);
Thanks
Johnny

Please mark this response as correct or helpful if it assisted you with your question.