I want to populate the multiple values into the order guide

vinod6
Tera Contributor

In table level i have field. Field name is Area this is choice field .For example Area is gas station selected . in table level it showing 

vinod6_0-1733124146254.png

I want to populate  the this values into values into order guide

vinod6_1-1733124256488.png

but here showing empty .please see the below script

 

I want to populate same thing

 

 

Script include: 

client callable is true. 

 

getItems: function() {
        //var department = this.getParameter('sysparm_department');
        var area = this.getParameter('sysparm_value');
        var obj = [];
        var imac = new GlideRecord('sn_hamp_bulk_request_items');
        //imac.addQuery('u_department.name', department);
        imac.addQuery('u_area', area);
        imac.addQuery('u_active', true);
        imac.query();
        while (imac.next()) {
           
            var thing = {
                "model": imac.u_model.product_catalog_item.toString(),
                "quantity": imac.u_quantity.toString(),
                "cost_code": imac.u_area.toString(),
                "mfg_part": imac.u_location_type.toString(),
                "country": imac.u_country.toString(),
                "department": imac.u_department.toString()
            };
            obj.push(thing);
        }
        return JSON.stringify(obj);
    },
   
    type: 'GetBulkRequestItems '
});
 
client script : On load
 
var AreaName = 'Gas Station';
    //}
    alert("Final Department Name: " + AreaName);

    var ga = new GlideAjax('sn_hamp.GetBulkRequestItems');
    ga.addParam('sysparm_name', 'getItems');  // The function name in Script Include
    ga.addParam('sysparm_value', AreaName);  // Pass department name as a parameter
    ga.getXMLAnswer(function(response) {
        var result = response;
        alert("Response from server: " + result);
        var obj = JSON.parse(result);
        alert("Objects: " + JSON.stringify(obj));
   
        g_form.setValue('imac_staff', JSON.stringify(obj));
    });
Please correct the above script
1 REPLY 1

Brad Bowman
Kilo Patron
Kilo Patron

Since the parameter contains the department name, uncomment the var department line and correct it to use the same this.getParameter name as you used in the Client Script addParam:

var department = this.getParameter('sysparm_value');

Or if this is the u_area value on your custom table, use it in that addQuery line instead as long as the values agree - a text string in this case.  If you checked the Client callable box after the script existed, it may not have add the extended object, so make sure the first two lines, before your function looks like this:

var GetBulkRequestItems = Class.create();
GetBulkRequestItems.prototype = Object.extendsObject(AbstractAjaxProcessor, {

If you're still not getting the expected alerts, add some gs.info or gs.addInfoMessage lines to the Script Include to confirm it is running, the value passed in from the client, and to see if any records are retrieved by the GlideRecord then you will see where it is going wrong.