Community
Showing results for 
Search instead for 
Do you mean 
Reply

Add a new subentity record- inser new row object

New Member
Posts: 9
Country: USA

Add a new subentity record- inser new row object

[ Edited ]

I  have read tge Custom Sub Entities Sdk guide but still cant manage to add a row to my custom entity "Multilingual".

Here is my code:

 

>find the subentity with the name multilingual and assign a manager for that entity

CustomEntityDescriptor multilingualDescriptor = ACTFM.CustomEntities.GetCustomEntityDescriptor("multilingual");

CustomSubEntityManager<multilingualTable> manager2 = ACTFM.CustomEntities.GetSubEntityManager<multilingualTable>("multilingual");

 

>Get a field descriptor for the subentity field Spanish

Act.Framework.CustomEntities.CustomEntityFieldDescriptor descr = manager2.GetCustomEntityFieldDescriptor("Spanish", FieldNameType.Alias);

 

>Add a new subentity objet-NOT WORKING

multilingualTable addedcustombject;
addedcustombject = manager2.CreateCustomEntity();

addedcustombject.Fields[descr.DisplayName, FieldNameType.Alias] ="123";

addedcustombject.Update();

 

 

I assume i am not using the CreateCustomEntity in the correct way?Any suggestions will be really appreciated, the guide states that is doable through the CreateCustomEnity method of the CustomSubEntityManager.

Highlighted
gkl
Copper Contributor
Posts: 29
Country: Ecuador

Re: Add a new subentity record- inser new row object

You need to set the parent Entity of the subentity for the new object to be saved and give the a list of  the parent entity

 

addedcustombject.SetContact(abc) ;// where abc is a list of  contacts that you get with the descriptor n the sorting

New Member
Posts: 9
Country: USA

Re: Add a new subentity record- inser new row object

Finally the customentity object-row is being added!But but but..i have set now all contact list as parent, my goal is to set one contact. Is there a method to assign it to one contact my customsubentity;

New Member
Posts: 9
Country: USA

Re: Add a new subentity record- inser new row object

[ Edited ]

I was thinking of ways to play around and overcome this difficulty by creating maybe a contact list with criteria. For example the name of the contact that i have just added and i want to set as parent of the new subentity(multilingual table) row. I cant seem to find a way to set filter criteria by name for a contact list though.

 

 

It seems from the manual that you can set one contact as parent, but is not very clear how, page 12-13 (http://community.act.com/sage/attachments/sage/ADN_Downloads/4/1/Custom%20Sub-Entities%20SDK%20Guide...

 

Any help would be really appreciated!!

Copper Contributor
Posts: 123
Country: Canada

Re: Add a new subentity record- inser new row object

[ Edited ]

If you only want to set one contact (using the current contact as example) you can use this where "abc" was:

 

Contact currentContact = actApp.ApplicationState.CurrentContact;

 

yourobject.SetContacts(actFwk.Contacts.GetContactAsContactList(currentContact));

 

may need to call yourobject.Update(); afterwards but I can't remember.

 

Hope that helps.

New Member
Posts: 9
Country: USA

Re: Add a new subentity record- inser new row object

actApp does not exist, I am propably missing a reference?I have just instantiated  new ActFramework

Copper Contributor
Posts: 123
Country: Canada

Re: Add a new subentity record- inser new row object

Are you using a plugin or just an external application?

 

Either way this might be what you're looking for:

Act.Framework.Contacts.ContactFieldDescriptor contField = actFwk.Contacts.GetContactFieldDescriptor("CONTACT", Act.Framework.MutableEntities.FieldNameType.Alias);

Act.Shared.Collections.SortCriteria[] sCriteria = new Act.Shared.Collections.SortCriteria[] { new Act.Shared.Collections.SortCriteria(contField, System.ComponentModel.ListSortDirection.Ascending) };

Act.Framework.IFilterCriteria[] fCriteria = new Act.Framework.IFilterCriteria[] { new Act.Framework.ComparisonFilterCriteria(contField, ComparisonFilterCriteria.Operation.Equals, "Contact Name to look for") };

ContactList cL = actFwk.Contacts.GetContacts(sCriteria, fCriteria);

 Then once you have that list you can run your SetContacts(cL) method.

Hope that helps.