How to add RIDAC on Program Level

swe5
Tera Expert

Related Lists
The related lists "Risk" (risk.top_program) and "Issues" (issue.top_program) are displayed OOTB. For the "Decision" (dmn_decision.top_program) exists one which can be inserted. For Action and Request Change related Lists must be created.

 

Create a related List
To do this, create a new list under System Definition -> Relationships.

 

Actions

action.png

 

(function refineQuery(current, parent) {
	
    var output = "parent=" + parent.sys_id;
    var encodedQuery = [];

    var dmn = new GlideRecord("dmn_demand");
    dmn.addQuery("primary_program", parent.sys_id);
    dmn.query();

    while (dmn.next()) {
        encodedQuery.push("parent=" + dmn.sys_id);
    }

    var prj = new GlideRecord("pm_project");
    prj.addQuery("primary_program", parent.sys_id);
    prj.query();

    while (prj.next()) {
        encodedQuery.push("parent=" + prj.sys_id);
    }

    if (encodedQuery.length > 0) {
        var encodedQueryStr = encodedQuery.join("^OR");
        current.addEncodedQuery(output + "^OR" + encodedQueryStr);
    } else {
        current.addEncodedQuery(output);
    }
	
})(current, parent);

 

 

 

Request Change

cr.png

 

(function refineQuery(current, parent) {
	
    var output = "parent=" + parent.sys_id;
    var encodedQuery = [];

    var dmn = new GlideRecord("dmn_demand");
    dmn.addQuery("primary_program", parent.sys_id);
    dmn.query();

    while (dmn.next()) {
        encodedQuery.push("parent=" + dmn.sys_id);
    }

    var prj = new GlideRecord("pm_project");
    prj.addQuery("primary_program", parent.sys_id);
    prj.query();

    while (prj.next()) {
        encodedQuery.push("parent=" + prj.sys_id);
    }

    if (encodedQuery.length > 0) {
        var encodedQueryStr = encodedQuery.join("^OR");
        current.addEncodedQuery(output + "^OR" + encodedQueryStr);
    } else {
        current.addEncodedQuery(output);
    }
	
})(current, parent);

 

 

Enable Related Links
The UI action "Convert to RIDAC" contains the following condition:

!current.isNewRecord() && current.canWrite() && gs.hasRole('project_manager, demand_manager') && (current.risk_state == '-5' || current.risk_state == '1' || current.risk_state == '2') && new RidacHelper().checkParentTask(current.task)

 

Therefore the script include "RidacHelper" respectively the function "checkParentTask" has to be extended as follows:

swe5_2-1678460083591.png

 

else if(parentTask.getRefRecord().instanceOf('pm_program'))
	return true;

 

 

Insert module

Under System Definition -> Modules insert a "View RIDAC" for Program Level:

swe5_3-1678460634088.png

Arguments

 

&sysparm_fixed_query=from_task.sys_class_name=pm_program

 

 

 

 

 

0 REPLIES 0