Related list copy

sip
Tera Contributor

Hello all ,

I have two tables Demand and Project where the Demand table is the parent table and the project is the child table of demand .

In the demand table ,there are two related list which are Stakeholders and Decision tabs .

Now the requirement is that I want the same two related list on my project table as it is in demand and Carry over any information from theses tabs into the Project when created.

Can anyone help me with how to proceed with this .

Any suggestions would be welcome 🙂 

1 ACCEPTED SOLUTION

There isn't any. Its just the columns that are being displayed in list view.

 

The Stakeholder for Demand has additional () part which I guess is the portfolio value while the one in Project has normal User name displayed.

You can check for the list layout once & then get it compared once for better understanding.

 

Thanks,

Jaspal Singh

 

Hit Helpful or Correct on the impact of response.

View solution in original post

22 REPLIES 22

Jaspal Singh
Mega Patron
Mega Patron

Hi,

 

We had a similar requirement that was to get the Stakeholder part copied. You can try & modify the below so as to get the Decision part copied over as well.

A after insert Business rule on Project table with below snippet.

(function executeRule(current, previous /*null when async*/) {

	//gs.log('Demand is ',current.u_demand);
	var dm=new GlideRecord('dmn_demand');
	dm.addQuery('sys_id',current.u_demand);
	dm.query();
	while(dm.next())
		{
			//gs.log('Demand sys id is ',dm.sys_id);
                        var dmstake=new GlideRecord('dmn_m2m_demand_stakeholder');
			dmstake.addQuery('demand',dm.sys_id);
			dmstake.query();
			while(dmstake.next())
				{
					//gs.log('Demand stakeholder user is ',dmstake.stakeholder.getDisplayValue());
					//gs.log('Demand stakeholder user is sysid ',dmstake.stakeholder);
					//var dmst=dmstake.stakeholder;
					//gs.log('Demand stakeholder parent is ',dm.sys_id.getDisplayValue());
					var stakereg=new GlideRecord('dmn_stakeholder_register');
					stakereg.addQuery('sys_id',dmstake.stakeholder);
					stakereg.query();
					while(stakereg.next())
						{
						//	gs.log('Demand stakeholder reg user is ',dmstake.stakeholder.getDisplayValue());
						//	gs.log('Demand stake depends on ',stakereg.user.getDisplayValue());
						//	gs.log('Demand stake depends on1 ',stakereg.user.getDisplayValue());
					var prjstake=new GlideRecord('u_project_stakeholders');
					prjstake.initialize();
					prjstake.u_name=stakereg.user;
					prjstake.u_business_unit=dm.u_business_unit;
					prjstake.parent=current.sys_id;
					prjstake.insert();
						}
				}
		}

})(current, previous);

Thanks,

Jaspal Singh

 

Hit Helpful or Correct on the impact of response.

sip
Tera Contributor

Hello Jaspal ,

First I would say thank you so much for the instant reply .But my concern is I dont have those two related list stakeholders and decision tab in my project table 

so shall I first create them and then use this BR script ?

Yes, if you could look in the script 

var prjstake=new GlideRecord('u_project_stakeholders');

is the part of inserting it in Project Stakeholder table created. 

 

Thanks,

Jaspal Singh

 

Hit Helpful or Correct on the impact of response.

sip
Tera Contributor

Hello Jaspal ,

I created a new relationship on project table and wrote this script but the problem is ideally the project should contain stakeholders only which is contained for that demand from which the project is created .

But now it is taking whole stakeholders .

Please advice.