Need to create a new value in alm_hardware table

vinuth v
Tera Expert

Hi All,

 

I am working on of the form in this form I am using multi row variable set and it contains Product Model, Keyboard Language, Quantity and Serial Number(Multi Line Text)

vinuthv_0-1697034589297.png

And on the serial number field we are giving the value like this 

 

vinuthv_1-1697034838666.png

 

outside variable set I have Acquisition method and Stock reservation fields.

I need to create a new record in the alm_hardware table using the serial number provide on the Serial Number field and that record will be created in the alm_hardware table.

While creating the record I need to map the selected "Acquisition method" to Acquisition method in the record and Product Model to Model in the record.

 

I tried with the below script it is working fine for the single variable (created new field out side the multi row variable set).

var serial_number = current.variables.serial_number.toString();
var arrSerialNumber = serial_number.split('\n');
for (var i in arrSerialNumber){
    insertHardwareBySerialNumber(arrSerialNumber[i]);
}

/**
 * Create new Hardware by Serial Number
 * @return {void}: insert new Hardware record
 */
function insertHardwareBySerialNumber(serial_number){
    var grHardware = new GlideRecord('alm_hardware');
    grHardware.addQuery('serial_number', serial_number);
    grHardware.query();
    if(grHardware.next()){
        return; //return if serial number existed.
    }

    //insert new hardware
    grHardware.initialize();
    grHardware.serial_number = serial_number;
    grHardware.install_status='1';
    grHardware.substatus='Commissioned';
    grHardware.model='Dell Latitude 5480';
    grHardware.stockroom='AE-Dubai-MediaCity-Stockroom';
    grHardware.location='AE - Dubai City';
    grHardware.insert();
}

 

 I need to create a record on the alm_hardware table using multi row variable set and need to update the above variables.

 

Please any one suggest me,

 

Thanks in advance,

Vinuth

0 REPLIES 0