01-13-2011 02:08 AM
Using Sage ACT! Premium 2011 Version 22.214.171.124, configured a plugin to return a list of fields.
Works fine for the Contact fields but is throwing an exception for opportunities, testing code to return first field below.
Act.Framework.Contacts.ContactFieldDescriptor cFields = application.ActFramework.Contacts.GetContactFieldDescriptors(); MessageBox.Show(cFields.Length.ToString()); MessageBox.Show(cFields.ToString());
Does Not Work (Opportunity)
Act.Framework.Opportunities.OpportunityFieldDescriptor oFields = application.ActFramework.Opportunities.GetOpportunityFieldDescriptors(); MessageBox.Show(oFields.Length.ToString()); MessageBox.Show(oFields.ToString());
Opportunities just appear to return null values.
01-13-2011 06:13 AM
FieldDescriptorCollection oFields = application.ActFwk.Fields.GetFields(Act.Framework.RecordType.Opportunity);
This will get you a collection of opportunity field descriptors. I had this in a sample from where someone else had asked the same question but I can't seem to recall why we had to use this approach for opportunities.
I'll go ahead and include a sample for retrieving product field descriptors incase that's something your going to want or need to do and because it's the only other thing I'm familiar with that can't be acquired via your first method.
CustomEntityFieldDescriptor prodFields = ActApp.ActFwk. Products.OpportunityProductManager.GetCustomEntityFieldDescriptors();
Also I typed this free hand so hopefully there aren't any mistakes.
01-14-2011 04:16 AM
Is this the same reason that the following code will not work?
OpportunityFieldDescriptor _opWriteBack = application.ActFramework.Opportunities.GetOpportunityFieldDescriptor("OPPORTUNITY_FIELD_7", false);
I've tried with the table name, changing false to including the type of field descriptor etc... it just seems to return null.
06-25-2012 10:33 AM
Actually the idea here works fine and we used the idea there when we develop a plugins for QwikQuote recently.
One little point is to figure out the exact internal field name after you successfully added the custom filed to the Product entity – especially the magic number at the ending part of the custom field. The dilemma is as long as you do not know that number, you cannot get the Custom Entity Field Descriptor of the custom field you added.
In process of developing a plugins for QwikQuote in a QwikQuote Customization project recently, we use the code similar as below to list all the Custom Entity Field Descriptors
Dim aryCustomEntityFieldDescriptor() As Act.Framework.CustomEntities.CustomEntityFieldDescriptor
aryCustomEntityFieldDescriptor = m_LiveActFW.Products.OpportunityProductManager.GetCustomEntityFieldDescriptors()
For Each soppPSCustomFieldDescriptor As CustomEntityFieldDescriptor In aryCustomEntityFieldDescriptor
Debug.Print (.TableName & " " & .ColumnName & " " & .Name)
And the typical output is as below
TBL_PRODUCTSERVICE CUST_SDKProduct_011749238 TBL_PRODUCTSERVICE.CUST_SDKProduct_011749238
TBL_PRODUCTSERVICE CUST_ExchangeRage_093258479 TBL_PRODUCTSERVICE.CUST_ExchangeRage_093258479
TBL_PRODUCTSERVICE UNITPRICE TBL_PRODUCTSERVICE.UNITPRICE
TBL_PRODUCTSERVICE UNITCOST TBL_PRODUCTSERVICE.UNITCOST
TBL_PRODUCTSERVICE ITEMCODE TBL_PRODUCTSERVICE.ITEMCODE
TBL_PRODUCTSERVICE EDITDATE TBL_PRODUCTSERVICE.EDITDATE
TBL_PRODUCTSERVICE CREATEDATE TBL_PRODUCTSERVICE.CREATEDATE
TBL_PRODUCTSERVICE EXTENDEDAMT TBL_PRODUCTSERVICE.EXTENDEDAMT
TBL_PRODUCTSERVICE DISCOUNTPRICE TBL_PRODUCTSERVICE.DISCOUNTPRICE
TBL_PRODUCTSERVICE QUANTITY TBL_PRODUCTSERVICE.QUANTITY
TBL_PRODUCTSERVICE CUST_ShippingWeight_100806979 TBL_PRODUCTSERVICE.CUST_ShippingWeight_100806979
TBL_PRODUCTSERVICE UNITDISCOUNT TBL_PRODUCTSERVICE.UNITDISCOUNT
TBL_PRODUCTSERVICE ITEMTYPE TBL_PRODUCTSERVICE.ITEMTYPE
TBL_PRODUCTSERVICE NAME TBL_PRODUCTSERVICE.NAME
With a little intelligent in string processing one can figure out which name is the right one to use
'TBL_PRODUCTSERVICE CUST_SDKProduct_011749238 TBL_PRODUCTSERVICE.CUST_SDKProduct_011749238
'TBL_PRODUCTSERVICE CUST_ExchangeRage_093258479 TBL_PRODUCTSERVICE.CUST_ExchangeRage_093258479
'TBL_PRODUCTSERVICE CUST_ShippingWeight_100806979 TBL_PRODUCTSERVICE.CUST_ShippingWeight_100806979
And then you can use the code similar as below to read from or writhe to the Product Custom Field:
Dim thisCustomEntityFieldDescriptor As CustomEntityFieldDescriptor = Nothing
thisCustomEntityFieldDescriptor = m_LiveActFW.Products.OpportunityProductManager.GetCustomEntityFieldDescriptor("TBL_PRODUCTSERVICE.CUST_SDKProduct_011749238", true)
Dim CustFieldVal_Old As String ' Nothing there in yet.
CustFieldVal_Old = thisCustomEntityFieldDescriptor.GetValue (soppProductServiceItem)
thisCustomEntityFieldDescriptor.SetValue (soppProductServiceItem, "Test Value!!!")
Dim CustFieldVal_New As String ' Now new value is: Test Value!!!
CustFieldVal_New = thisCustomEntityFieldDescriptor.GetValue (soppProductServiceItem)
06-26-2012 01:05 AM
I found that for some reason with opportunities mutableentityfielddescriptor works much better then opportunityfielddescriptor
so for instance, this:
MutableEntityFieldDescriptor dobfielddescriptor = ACTFM.Opportunities.GetMutableEntityFieldDescriptor("Date Of Birth MA", FieldNameType.Alias);
works whereas using the opportunityfielddescriptor gives errors.