AutoPopulate Project manager tagged to project

Mehar Naaz
Tera Contributor

I want to auto populate project manager tagged to particular project. When Project manager is selected a choice field should have all the list of project tagged to that project manager.

11 REPLIES 11

Hi,
You can use the advance reference qualifier on project variables. Sample screenshot attached.

SaurabhGupta_0-1703571646817.png

 

C

If the provided solution meets your needs, kindly consider marking it as helpful and accepting it as the solution. This helps others who may have similar questions.

 


Thanks and Regards,

Saurabh Gupta

Pankaj kr
Kilo Sage

Hi Mehar,

 

  1. If the data type of project is a 'Lookup select box' you can use reference qualifier to like with backend names of your variable as below-

 

javascript; "u_project_manager="+current. variables.project_manager;​

 

  • If you are using select box you have to write on change client script for the list value autopopulation. 

Please mark my answer helpful if it solved your issue.

 

Thanks,

 

Pankaj Kumar

 

 

 

you can learn more here: KB Article 

Yes its type is select. I have written these Catalog client script and script include. But it is giving NULL value.

 

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.query();

        gs.log('prj1:' + prj);

        if (prj.next()) {

            gs.log('prj2:' + prj);

            //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'

});

---------------------------------------------------------------------------------------------------------------------------------

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);

       

    }

}

 

HI Mehar,

 

It is better to use lookup select box in this place and go to type specification tab and do the following-

Lookup from table: pm_project

Lookup value field: Project manager
Include none :
Unique values only: 
Reference qualifier: 

 

javascript: "your_lookup_table_field_name="+current. variables.project_manager;​

 

 
 if you want more to add here you do following-
 

 

javascript: "your_lookup_table_field_name="+current. variables.project_manager+ "^your_lookup_table_2ndfield_name="+current. variables.other_variable_name;​

 

It is the best practice, so i will recommend you to go this way instead of writting the scripts.
 
But coming to the error part of query.
You have to use 
g_form.addOption(), multiple time by iterating through the XML response to set the options you need.
 
Thanks,
 
Pankaj Kumar

I tried your approach. Right now it is populating Project manager without any project selected.

The requirement is whenever a project is selected the project manager tagged to that project should populate in below field.