05-13-2011 12:16 PM
I've seen a couple of different posts that deal with returning the current user. However, my issue is assigning this user to be the account manager for an opportunity. Our goal is to not default the account.accountmanager but rather have the opportunity.accountmanager be the current user.
I am going about this by using the OnCreate method for the Opportunity object. I have added a post execute step and have the code:
public static voidOnCreateStepSetDefaults( IOpportunity opportunity)
Sage.Entity.Interfaces.IUser usr = Sage.SalesLogix.API.MySlx.Security.CurrentSalesLogixUser
opportunity.AccountManager = usr;
This doesn't error, but when i bring up the insert opportunity screen, the acct manager is still the acct.acctmgr and not the current user. Any idea where I'm going wrong?
Solved! Go to Solution.
05-14-2011 04:16 AM
The challenge I've run into with this sort of thing is that business rules are perhaps useful for setting default values but often their overridden some where in the interface design which means you can set up all the onCreate steps you want but if the interface logic is changing the value after the entity has been created your defaults will always get overridden.
I think your best bet is to see where on the insert opportunity function the opportunity entity is being populated in the interface code (i.e. after the new entity has been created but before it's rendered to the end user) and override the logic there.
05-18-2011 08:38 AM
If anyone were intereseted, I did figure this out.
There is validation code on the load of the screen and that is what sets the Acct Mgr, so teh code on the Opportunity object gets overridden. So, to set the account manager to the current user, you need to:
Open Load Actions on the Insert Opportunity Form
Add another member to the load actions.
Choose C# snippet Action Item(obsolete)
For the code, use:
Sage.Entity.Interfaces.IUser usr = (Sage.Entity.Interfaces.IUser)Sage.SalesLogix.API.MySlx.Security.CurrentSalesLogixUser;
usrUser.LookupResultValue = usr.Id;
Save everything, build and deploy.
Hope it helps,
08-31-2011 12:22 AM - edited 08-31-2011 02:07 AM
More specifically, it's the 'CheckOppAccount' business rule found in Sage.SalesLogix.Opportunity.Rules and which gets run once the Account has been set/defined in the interface (it sets the AM to the Account.AM -- it's the OnChangeAction for the lueAccount lookup). It's a small script that can be either replaced (remove 'Primary Step' and replace), override with a 'Post Execute Step' or simply reset in the interface using an OnChange event on the lueAccount field.
Also found in: