Programatically Set the Lookup for an Acccount Based on the Contact That is Selected in SalesLogix

Question: In SalesLogix how can I programatically set the lookup for an account based on the contact that is selected?  I am having trouble getting the contact name to appear in the lookup even though I can get the accountid to save in the database.  This is my code:

public static void lueFirmContact_OnChangeSetAccountStep( IJobContacts form, EventArgs args)
{
IContact firmContact = form.lueFirmContact.LookupResultValue as IContact;

IAccount firmAccount = firmContact.Account as IAccount;

form.lueFirmAccount.LookupResultValue = firmAccount;

form.lueFirmAccount.Text = firmAccount.AccountName;

IC_Opportunity_Ext oppExt = (form.CurrentEntity as IOpportunity).C_Opportunity_Ext;

oppExt.IndpndntAdjFirmAcctId = firmAccount.Id.ToString();

oppExt.Save();
}

How can I get the account name to appear in the lookup lueFirmAccount?

Answer: Instead of trying to set the control, set the property in the entity. Also, instead of setting the lookup on the change event of the contact lookup, do something like this in C# snippet:

Sage.Entity.Interfaces.IMyEntity myentity = this.BindingSource.Current as Sage.Entity.Interfaces.IMyEntity;

myentity.Account = (Sage.Entity.Interfaces.IContact)lookupContact.LookupResultValue;After the postback the account lookup should show the bound value just fine.

Submit a Comment

Your email address will not be published. Required fields are marked *

Subscribe To Our Newsletter

Join our mailing list to receive the latest Infor CRM (Saleslogix) and Creatio (bpm'online) news and product updates!

You have Successfully Subscribed!