cancel
Showing results for 
Search instead for 
Did you mean: 

Problem in reading custom collection in Master Agreement.

ritikbaral
Explorer
0 Kudos

Hi All,

I have created a Custom Collection for Approvers and added the same under the Master Agreement. After adding the values to the ‘ApproverCollection’ in Master Agreement, when I am trying to read this Custom Collection . It’s saying the collection is empty, it returning null.

Following is the code:

ExtensionCollectionIfc approverCollection = doc.getExtensionCollection("ApproverCollection");

log.setLogMessage("Approvers: " + approverCollection + "---");

Logger.error(log);

I tried in a different way, but I got the same result ‘null’.

typeHome = IBeanHomeLocator.lookup(session, doc.getDocTypeReference());

typeBean = typeHome.find(doc.getDocTypeReference());

ExtensionCollectionIfc custColl = typeBean.getExtensionCollection("ApproverCollection");

log.setLogMessage("Cust Coll Approvers: " + custColl + "---");

Logger.error(log);

Any help on this will be greatly appreciated.

Thanks,

Ritik

Accepted Solutions (0)

Answers (2)

Answers (2)

ritikbaral
Explorer
0 Kudos

Hi Devesh,

Thanks for your input .

I was accessing the Custom Collection which is there in Master Agreement in wrong way:

ExtensionCollectionIfc approverCollection = doc.getExtensionCollection("ApproverCollection");

log.setLogMessage("Approvers: " + approverCollection + "---");

Logger.error(log);

It should be like the following:

AgrBean = doc.getParentIBean();

CustColl = AgrBean.getExtensionCollection("CUTSOM_COLLECTION_ON_MA");

Now i am facing some issue while deleting/adding the entries in Custom Collection.

For some reason its neither deleting the entries from the collection nor adding the entries to the collection.

Following is my code:

extColl = AgrBean.getExtensionCollection("COLLECTION");

AgrBeanHome = AgrBean.getIBeanHomeIfc();

AgrBeanHome.upgradeToEdit(AgrBean);



// for Delete


for (iter = extColl.size(); iter > 0; iter--)

{

        member = extColl.get(iter-1);

        log.setLogMessage("User Name: " + member.get("USERNAME"));

        Logger.error(log);

        extColl.delete(member);

      }

//For adding entries:

newMember = extColl.create();

newMember.set("USERNAME","1234");



I checked whether the agreement is in edit mode or not by using the following method:

AgrBean.isObjectAccessModeEdit();

This method returned 'true', which means the Agreement object is in edit mode.I do not know, where i am doing wrong.

Looking forward for your help on it.

Thanks,

Ritik

Former Member
0 Kudos

Your code for add seems to be missing the code to add the new member back to the collection.

newMember = extColl.create();

newMember.set("USERNAME","1234");

extColl.add(newMember)

ritikbaral
Explorer
0 Kudos

Hi Manali,

My bad, yes i just checked the 'add' part was missing , but the delete code is fine rite, I am wondering why thats not working .

The other thing is, i am facing the same issue while updating the custom extension field in my master agreement.

I am upgrading the MA to edit mode. Setting a value for the Custom Extension field. But unable to see the value , when i am going to the Custom extension field in MA.

Thanks a lot for all your help. Appreciate it.

Thanks,

Ritik

Former Member
0 Kudos

Hi Ritik,

I am not sure of the way you are trying to write the collection into the log.

log.setLogMessage("Approvers: " + approverCollection + "---");

Logger.error(log);

I think the error that you are getting maybe because you are directly accessing the collection variable (object) and the system is trying to convert it into a string representation (since you are concatenating it with strings).

I think a better way to determine whether the collection is empty should be to use the collnName.size(). You can try this and let us know if you are still facing errors.

Thanks

Devesh