In Asset table under related list populate a RMA line item

vinod6
Tera Contributor

I am trying to populate the "RMA Request Line Item" section in the  alm_asset table based on a condition from the sn_hamp_asset_reclaim_task table where the evaluation_status is "needs_repair" Since the RMA_Request Line Item is part of a different table (sn_hamp_rma_request_line) you'll need to create a relationship between these tables and ensure data is filtered properly. This two tables common field is Asset. Please look into the below script but it is not working.

I want to poulate alm_asset table. see the below one

vinod6_1-1729685154184.png

 

var gr = new GlideRecord('sn_hamp_asset_reclaim_task');
gr.addEncodedQuery("task_name=evaluate^evaluation_status=needs_repair");
gr.query();
while (gr.next()) {
task.push(gr.asset_reclaim_line.asset.toString());
}
gs.info("Assets in task array: " + task);

if (task.length > 0) {
var kk = new GlideRecord('sn_hamp_rma_request_line');
kk.addQuery('asset', 'IN', task);
kk.query();

while (kk.next()) {
gs.info("Matched RMA request line sys_id: " + kk.sys_id.toString());
}
}

current.addQuery('asset', 'IN', task);

1 REPLY 1

anshul_goyal
Kilo Sage

Hi @vinod6,

You can try using the following script:

 

 

var gr = new GlideRecord('sn_hamp_asset_reclaim_task');
gr.addEncodedQuery("task_name=evaluate^evaluation_status=needs_repair");
gr.query();
while (gr.next()) {
    task.push(gr.asset_reclaim_line.asset.toString());
}
gs.info("Assets in task array: " + task);

if (task.length > 0) {
    for (var i = 0; i < task; i++) {
        var kk = new GlideRecord('sn_hamp_rma_request_line');
        // kk.addQuery('asset', 'IN', task);
        kk.addEncodedQuery('asset.sys_idIN=' + task[i]);
        kk.query();
        while (kk.next()) {
            gs.info("Matched RMA request line sys_id: " + kk.sys_id.toString());
        }
    }
}
current.addQuery('asset.sys_idIN=' + task[i]);

 


Please mark my solution as Helpful and Accepted, if it works for you in any way!

Thanks