Community
Showing results for 
Search instead for 
Do you mean 
Reply

Modifying Field Attributes in a Plug-in

Copper Contributor
Posts: 28
Country: Canada

Modifying Field Attributes in a Plug-in

I have a plug-in with custom sub-entittes and everything is more or less fine, except one field has too short a fieldproperty.length.  Is there a way to alter this value short of stripping the table and re-adding it (what I was doing before this went live and only using dummy data.  Not an option at the moment).

Employee
Posts: 1,163
Country: USA

Re: Modifying Field Attributes in a Plug-in

This is straight off the top of my head and without the assistance of an editor so it might be a bit off, but once you have the field descriptor it should look something like:

 

myDBFieldDescriptor.Attributes[FieldDescriptorProperty.Length] = new ActApp.ActFramework.Fields.FieldDescriptorProperty.Length(Value);

 

Hopefully that's not too far off the mark.

Matthew Wood
Act! SDK Support
Community Moderator
Copper Contributor
Posts: 28
Country: Canada

Re: Modifying Field Attributes in a Plug-in

This doesn't seem to work.   

 

The code originally reads as

 

If entity doesn't exist

   Create Entity

End

 

I added an else statement, to jutst change the field attribute.  However, my issue is that it's not a new field.  It's an existing one whose attributes need to be updated.  Not saving causes the changes to be complete ignored.  Using the Fields.Save command causes an exception.

 

Any other thoughts?

Employee
Posts: 1,163
Country: USA

Re: Modifying Field Attributes in a Plug-in

What exception and what field are we trying to change the attributes of?

Matthew Wood
Act! SDK Support
Community Moderator
Copper Contributor
Posts: 28
Country: Canada

Re: Modifying Field Attributes in a Plug-in

Sorry for the lte replies, I can only lock the database at the end fo teh day.

 

I'm getting 'The descriptor name <NAME> is already in use adn cannot be applied.  It's the use of the word 'NEW' as this is a fild that's already been created in the Plug-in, I just need to modify its attributes at the moment.

 

Is there a way to just do a 'Get' on the given field descirptor than trying to create a new one?

Employee
Posts: 1,163
Country: USA

Re: Modifying Field Attributes in a Plug-in

Absolutely, there are several different Get methods for field descriptor, I'd refer to the code reference for all that are available, in the meantime here's an example of grabbign the edit date field from contacts:

 

DBFieldDescriptor EditDate = _ActApp.ActFramework.Contacts.GetFieldDescriptor("TBL_CONTACT.EDITDATE"true);
Matthew Wood
Act! SDK Support
Community Moderator
Copper Contributor
Posts: 28
Country: Canada

Re: Modifying Field Attributes in a Plug-in

However, the issue is that the field in is a part of a custom entity.  I create it just fine using the New FieldDescriptor command, I just am having issues editing it in situ.

 

Not sure if it's relevant, but this plug-in has a COMPANY as a parent, not CONTACT.