cancel
Showing results for 
Search instead for 
Did you mean: 

Can not get parentIBean from MA in 'Created' context script.

Former Member
0 Kudos

Hi experts,

I need some suggestion from your guys. I would like to create the MA from Project Document, and check whether the Project's status should not be 'Pending' to generate the MA. So i write the following script in 'Created' context of MA.

displayName = doc.getDisplayName();
project = doc.getParentIBean();

logInfo("Var project : "+project);
logInfo("Var displayName : "+displayName);

status = project.getStatus().getDisplayName(session);

if(hasValue(status) @and status.equals("Pending")){
	logInfo("Hit If");
}else{

}

When i try to create the MA from Project document, i realize from the log that the the project and displayName variable are 'null'. The script can not get ParenIBean and Display Name. I just want to get the ProjectIBean from the created MA. Can you suggest me to get the ProjectIBean from MA.

Thank you in advance,

Noppong

Accepted Solutions (1)

Accepted Solutions (1)

Former Member
0 Kudos

Hi

What I understand of your requirement is that you have a project from within which you are trying to create a new master agreement using script. In the code that you have mentioned, it seems doc is pointing to project rather than master agreement that is why doc.getParentIBean() method is returing a NULL value.

I may be wrong here so plz verify with getIBeanHomeIfc() method to check.

Regards

Mudit Saini

Former Member
0 Kudos

Hi Mudit,

Thank for your response.

I create MA by choosing Action->Create Master Agreement from Project's toolbar, not from script. So the above code is in 'Created' event of MA. The requirement is i would like to check project's status in 'Created' event of MA. If the project status = 'Pending', not generate the MA. That why i need to have ProjectIBean to get the status from the project.

Thank you

Noppong

Former Member
0 Kudos

Hi

I don't thing what you need would be possible with "Create" context. I would suggest "Saved" or "Validated" context. I understand this might not provide the exact solution as you desire (of MA not getting created at all in case of anomaly) but still since MA getting created doesn't mean it is saved as well.

This seem to me to be the best possible approach.

Regards

Mudit Saini

Former Member
0 Kudos

Hi Mudit,

Thanks for your reply.

I've tried to write script in 'Validate' context as your advice, but i still can not get the parent document(ProjectIBean) from MA. I'm not sure whether the project has relationship with MA as the parent when we create MA from the project. Because when i invoke 'doc.getParentIBean()' in Validate context of MA, it always returns null value. I have to get the ProjectIBean from the DocumentLinks collection by iterating them.

I'm not sure whether this is the best way to get ProjectIBean from MA or not. Is there any easy way? Please suggest

i wrote the script to get the ProjectIBean like the following.

docLinkColln = doc.getAllDocumentLinks();
docLinkItr = docLinkColln.iterator();
for(member : docLinkItr){
	// member is DocumentLinkIBeanIfc class.
	docRef = member.getLinkDocObjRef();
	classId = docRef.getClassId();
	logInfo("Var docRef.getClass() : "+docRef.getClass());
	logInfo("Var docRef.getDisplayName() : "+docRef.getDisplayName());
	logInfo("Var classId : "+classId);
	if(classId == 1100){
		project = IBeanHomeLocator.lookup(session,docRef).find(docRef);
		logInfo("Var project.getDisplayName() : "+project.getDisplayName());
		logInfo("Var project.getStatus().getDisplayName(session) : "+project.getStatus().getDisplayName(session));
	}
}

Noppong,

Thank you so much

Former Member
0 Kudos

Hi,

As MA and Project are two distinctive parallel high level objects, doc.getParentIbean() construct would not work. This would work only cases where the objects are associated through a collectoin. For instance, for a contract document, doc.getParentIbean() will return reference to MA instance. Similarly lineItem.getParentIbean() will return the corresponding parent like Rfx ,MA etc..

As you already figured out the only link between two highlevel docuemnts is the document links & the code you mentioned is the way to go..

Thanks,

Baski

Former Member
0 Kudos

Hi Baski and Mudit,

Thank you guys. I am so appreciated your reply.It make me clear.

Thank you,

Noppong

Answers (0)