Join the #BuildWithBuildAgent Challenge! Get recognized, earn exclusive swag, and inspire the ServiceNow Community with what you can build using Build Agent.  Join the Challenge.

How to fetch delivery manager of selected project?

Supriya P
Tera Contributor

I have created record producer.

SupriyaP_0-1703249094397.png

 

where, I am fetching projects which are tagged to 'Project Manager' in 'Project' variable below the Project manager variable.

(Multiple projects are assigned to project manager)

The requirement is,

if project manager selects 1 project then BCP Approver should be autopopulated with the delivery manager of the selected project.

How can we achieve this scenario?

1 ACCEPTED SOLUTION

@Supriya P 

that's correct.

Your variable is not reference type?

It should be reference type. User won't remember project name and it should not be a text variable

If my response helped please mark it correct and close the thread so that it benefits future readers.

Regards,
Ankur
Certified Technical Architect  ||  9x ServiceNow MVP  ||  ServiceNow Community Leader

View solution in original post

5 REPLIES 5

Yes. The variable type is select box.

I have written a script include and catalog client script but the delivery manager of selected project is not getting populated when the project is selected.

 Script Include:

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

    deliveryManager: function() {
        var projectName = this.getParameter('sysparm_prjName');
        // var projectList = [];
        var x = '';

        var prj = new GlideRecord('pm_project');
        //prj.addQuery('short_description', projectName);
        prj.addEncodedQuery('short_description=' + 'Acme Workday to Payroll Automation'); //'Acme Workday to Payroll Automation'
        //prj.addEncodedQuery('active=true^short_descriptionIN');
        prj.query();
        gs.log('prj1:' + prj);
        if (prj.next()) {
            gs.log('prj2:' + prj);
            //  projectList.push(prj.short_description.getDisplayValue());
            //x=  prj.getValue('u_delivery_manager');
            x = prj.u_delivery_manager;
            gs.log('prj3:' + x);

        }
        return x;

        //short_description=Acme Workday to Payroll Automation


    },

    type: 'fetch_delivery_manager'
});
 
Catalog client script:
 
function onChange(control, oldValue, newValue, isLoading) {
    if (isLoading || newValue == '') {
        return;
    }
//var a=g_form.getValue('project');
//g_form.addInfoMessage(a);
    var ga = new GlideAjax('sn_bcm.fetch_delivery_manager');
    ga.addParam('syaparm_name', 'deliveryManager');
   // ga.addParam('sysparm_prjName', g_form.getValue('project'));
    ga.getXML(projectDetails);
    alert('hi');

    function projectDetails(response) {

        var answer = response.responseXML.documentElement.getAttribute("answer");
        alert(answer);
        //if(answer== true){
            //var result = JSON.parse(answer);
        g_form.setValue('bcp_approver', answer);
       
    }
}
In alert(answer) i am  getting null value
Can you please help me with the same issue.