Question

Best ways for setting default values based on database selection?

  • 27 December 2012
  • 1 reply
  • 11 views

We are working with a particular SmartForm where one of the key requirements is that we need to be able to call a SmartObject, based on criteria fields that have been set by the user in the form, and pull back a collection of fieldName/fieldValue pairs that we should then use to set the default values for text boxes and drop-down lists. 


There are 20+ rows that are going to come back from this SmartObject and I didn't see an easy way to meet this requirement, so I'm looking at creating a custom SmartForm control that would utlize jQuery to set these values.  I'm also assuming I'd need to configure whatever is necessary to expose the SmartObject as a service so that I can call it with some JavaScript code.


One of the challenges is matching up the fieldName from the SmartObject with the right field on the form as the IDs that I'm finding on the markup are really odd (e.g., 00000000-0000-0000-0000-000000000000_cadcc899-1890-7eef-6ba2-e5060bba226c_DropDown). 


Does anyone A) know if it's possible to influence the IDs that are generated during the rendering of the SmartForm (as it stands now, I'm thinking I'll have to create some sort of mapping of those funky IDs with the fieldNames from the database).  The intent is for end-users to be modifying this table of default values, so we don't necessarily want to have them dealing with these long IDs.  Or 😎 have any other suggestions, other than what I'm pursuing now with the custom control?


Thank you.


MK


1 reply


Hi MK


 


I would just like to make sure I understand your scenario...




  • - You have a Form which requires the user to enter data at runtime

  • - This data is then passed on to a SmartObject

  • - The SmartObject executes a list method based on the criteria provided, and returns a list of values

  • - The list of values should then be used to populate controls residing on the Form



Is this correct?


 


Then additionally:



  1. How would you populate textboxes on your Form when returning a list of values? Do you intend to use a specific row?

  2. The drop-down lists residing on your Form, are they all based on the same data source? Is your intention to populate them with the entire list returned from the SmO mentioned in the solution above, or do you want to filter them using a specific row?


I'm just curious as to why you return a list of values in order to populate multiple controls.


 


Kind regards,


Eugene


Reply