Community
Showing results for 
Search instead for 
Do you mean 
Reply

Retrieving Fields

Copper Contributor
Posts: 119
Country: USA

Retrieving Fields

by TDavis on 12-17-2007 2:09 PM

I've been playing with the new custom entities feature and have a question....

After you have created the custom entity is there any way to find out what parent entity it was attched to at a later date.  This would be obvious if you were building a specific plugin for a customer as you know whether it was contacts/companies etc. you attached it to but I'm trying to make a basic UI which allows the user to create the entity and specifiy themselves.

 Tom

Copper Contributor
Posts: 119
Country: USA

Re: Retrieving Fields

by Mark on 12-17-2007 5:27 PM

You can get the parent entities of a custom sub-entity from metadata.

On ActFramework use the SchemaMetaData property and on SchemaMetaData use EntityByName["SUBENTITYNAME"].ParentEntities.

This returns an array of Entity objects for the parent entities.

Thanks for posting this though, it brings up an issue that there should be an easy way to get back the ParentEntity bit mask that was used to create the custom entity.  The reason metadata returns Entity objects is because in the future a custom entity could be the parent for a custom sub-entity.

There should probably be a ParentEntity property on the CustomEntityDescriptor so you can quickly get the parent entity/entities.


Mark 

Copper Contributor
Posts: 119
Country: USA

Re: Retrieving Fields

by TDavis on 12-18-2007 4:07 AM

Thanks for your help Mark - one other thing I forgot to ask is when you want to delete a field how do you obtain it.  I cannot find a way to get the field as anything other than CustomEntityFieldDescriptor but I would like to get it as Act.Framework.Database.FieldDescriptor so I can use Act.Database.Fields.Delete(field).

 

Tom

 
Copper Contributor
Posts: 119
Country: USA

Re: Retrieving Fields

by TDavis on 12-18-2007 9:29 AM

I have found this way but it seems a bit long-winded to loop through every field:

Dim fields As Act.Framework.Database.FieldDescriptorCollection = ActApp.ActFramework.Fields.GetFields(descriptor)

For Each field As Act.Framework.Database.FieldDescriptor In fields

If field.Alias = AliasName Then

ActApp.ActFramework.Fields.Delete(field)

End If

Next

Copper Contributor
Posts: 119
Country: USA

Re: Retrieving Fields

by Mark on 12-18-2007 11:13 AM

Yeah the define fields API wasn't changed for custom sub-entities so it's the same way you would delete a field for contacts, groups, and companies.

The FieldDescriptorManager (define fields API) needs a more user friendly public interface, it was written to support the define fields UI.