7/6/2025 1:29:58 PM
|
|
slxdeveloper.com Community Forums |
|
|
|
The Forums on slxdeveloper.com are now retired. The forum archive will remain available for the time being. Thank you for your participation on slxdeveloper.com!
Forum to discuss the use of the SalesLogix Web Platform, Client and Customer Portals, and the Application Architect (For version 7.2 and higher only). View the code of conduct for posting guidelines.
|
|
|
|
v7.5 - Automatically Populate Form Field
Posted: 20 May 09 1:57 PM
|
Can someone tell me how to automatically populate a DialogWorkspace form field? I have an AddEdit form that I would like to display default values in certain fields whenever the form is lauched in "Add" mode. If the user hits the "add" button, and immediately hits "OK" on the form, I want certain values to be saved in the new record.
Thanks!
Jim M. |
|
|
|
Re: v7.5 - Automatically Populate Form Field
Posted: 20 May 09 2:12 PM
|
I have found that the easiest was to use an "OnCreate" event handler at the entity level (defined in App Architect - I run mine as a post execute step of the default event handler) |
|
|
|
Re: v7.5 - Automatically Populate Form Field
Posted: 27 May 09 10:38 AM
|
I'm afraid that the event handlers are new to me. I looked at the properties of some existing ones (under AccountProduct), but I don't see any code. AccountProduct has an OnCreate Primary step method, but there aren't any code snippets defined, so I can't tell what it is doing.
If I go under my entity ("CEngOpp") I 2x click on the OnCreate event. On the "post execute steps" tab, I hit add and choose "C# code snippet". I leave the default snippet name ("OnCreateStep1"), and choose OK. I then have the option to "edit code snippet".
At this point I have a test field called "txtJimField", that is linked to a back end database field. All I want to do is a put a value in this form field, so when a user brings up my AddEdit form in "Add" mode and immediately hits the "OK" button, a default value is stored in the database. I tried to use code in my snippet that said txtJimField.Text = "test Value", but when I built the web platform I got an error that said "txtJimField" does not exist in the current context.
I suspect that what I am trying to do is pretty simple, but I am really a novice with this version of the product.
Am I approaching this correctly?
Thanks for any help!
Jim M. |
|
|
|
Re: v7.5 - Automatically Populate Form Field
Posted: 27 May 09 3:07 PM
|
You are almost there, but inside of the event handler you can only work with the entity properties, not with the fields on the form.
So your snippet would look something like (e.g. for the account product): public static void OnCreateStep(IAccountProduct accountProduct) { accountProduct.JimField = "Whatever"; }
Then when your form opens it will pull this value from the entity and display it. |
|
|
|
Re: v7.5 - Automatically Populate Form Field
Posted: 28 May 09 3:10 PM
|
OK! I've been able to set default string field values by using an OnCreate event as follows (thanks Nicolas!)
****************** public static void OnCreateStep1( ICEngOpp cengopp ) { cengopp.Name = "{Enter an Eng. Opp. Name}"; } ****************** My final step is to populate the form fields with values from the account table. I tried the following with no luck.
****************** public static void OnCreateStep1( ICEngOpp cengopp ) { cengopp.Name = "{Enter an Eng. Opp. Name}"; cengopp.AccountType = cengopp.Account.Type; cengopp.AccountCity = cengopp.Account.Address.City; } ******************
I also tried this approach ****************** public static void OnCreateStep1( ICEngOpp cengopp, IAccount account ) { cengopp.Name = "{Enter an Eng. Opp. Name}"; cengopp.AccountType = account.Type; cengopp.AccountCity = account.Address.City; } ******************
The software didn't like either approach in the OnCreate event.
|
|
|
|
Re: v7.5 - Automatically Populate Form Field
Posted: 28 May 09 4:21 PM
|
This is a bit tougher because you don't have access to the parent entity within the business rule... so if you try this: cengopp.AccountType = cengopp.Account.Type;
It will probably give you a null reference exception.
This one does not work because the OnCreate only takes 1 parameter... so the second one won't be filled:
public static void OnCreateStep1( ICEngOpp cengopp, IAccount account )
However, you could create a new custom business rule, say "GetAccountDefaults":
public static void GetAccountDefaults( ICEngOpp cengopp, IAccount account )
Then call it from your form (in the Load action):
((Sage.Entity.Interfaces.ICEngOpp)BindingSource.Current).GetAccountDefaults((Sage.Entity.Interfaces.IAccount)GetParentEntity())
For example Saleslogix has a business rule on the Opportunity called CheckOppAccount that gets the values from the account - they call it from the form when the user picks an account. |
|
|
|
Re: v7.5 - Automatically Populate Form Field
Posted: 29 May 09 10:58 AM
|
I had two threads going that appear to have morphed into the same subject. This thread defines how to populate bound form fields with default strings using an OnCreate event. My new problem is trying to populate bound form fields with values from the parent entity (instead of default strings).
Rather than maintaining both threads (and confusing myself), I'm going to post any follow up to the thread titled "v7.5 - How to Pass Account Field Values to AddEdit form?"
|
|
|
|
You can
subscribe to receive a daily forum digest in your
user profile. View the site code
of conduct for posting guidelines.
Forum RSS Feed - Subscribe to the forum RSS feed to keep on top of the latest forum activity!
|
|
|
|
|
|
|
|