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

Why don't you create reference field?

You have created a variable of select box, its choices are not fixed and you want to select data from user table (project manager is form user table). It is always good to create reference field and return the Project Manager sys_id from Glide Ajax.

Otherwise create a variable of type Lookup select box as mentioned by @Pankaj kr  and use proper reference qualifier.

Also what is the type of "Project" variable?

Please appreciate the efforts of community contributors by marking appropriate response as correct answer and helpful, this may help other community users to follow correct solution in future.
Thanks
Anil Lande

I have tried using reference type of the particular field but I am getting all the projects in that field. It should show only projects which is assigned to project manager. 

Another scenario is when the project is in cancelled state it should be visible in the project list.

I tried the below scripts:

 

 

function onLoad() {

    var ga = new GlideAjax('fetch_projects_reference_type');

    ga.addParam('sysparm_name', 'fetchProjects');

    ga.addParam('sysparm_reqFor', g_form.getValue('bcm_lead'));

    ga.getXML(projectDetails);

 

    function projectDetails(response) {

        var answer = response.responseXML.documentElement.getAttribute("answer");

        alert(answer);

    //  if(answer=='true'){

      g_form.setValue('projects', answer);

        }

    }

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

var fetch_projects_reference_type = Class.create();

fetch_projects_reference_type.prototype = Object.extendsObject(global.AbstractAjaxProcessor, {

    fetchProjects: function(reqFor) {

 

        var answer = "sys_id=none";

        // var reqFor = this.getParameter('sysparm_reqFor');

        gs.addInfoMessage("hi:" + reqFor);

        var projects = [];

        var prjManager = [];

 

        var prj = new GlideRecord('pm_project');

        prj.addQuery('project_manager', reqFor);

        // prj.addEncodedQuery('active=true^short_descriptionIN');

        prj.query();

        while (prj.next()) {

            gs.addInfoMessage("hi:" + prj);

            // projects.push(prj.sys_id);

            projects.push("" + prj.sys_id);

 

        }

        answer = "sys_idIN" + projects.toString();

        return answer;

 

    },

    type: 'fetch_projects_reference_type'

});