I had a situation where I have a UX component and upon submitting a record this UX would send an email TO and CC specific users.
The email users were basically hard coded into the javascript but I wanted to create a database table that would have the user emails that I wanted TO and CC based on a Group filter instead giving greater flexibility.
So, I created a SQL table EmailGroups that would hold EmailID, EmailGroup, EmailTo, and EmailCC.
PROBLEM
I had no way to link the EmailID to the current table in the UX in any meaningful way.
SOLUTION
Here is a method I ended up using to get a list of user emails from a SQL table.
1. Added a List component (MailList) to the UX which was based on the SQL table and filtered using a where clause to return only EmailTo and EmailCC users from a particular EmailGroup.
2. Added 2 textbox controls to the UX (EmailTo and EmailCC).
3. Used an event (could be a button click or onchange event, etc.) to trigger the following javascript which will populate the EmailTo and EmailCC fields from the SQL filtered List control.
This was done using the {dialog.object}.listGetValue() and {dialog.Object}.setValue() events like this:
The ['LISTNAME','CONTROLNAME',0] option will select the first row of the list, but in my SQL filtered list there is always only one row.
4. Used {EmailTo} and {EmailCC} placeholders instead of hard coded user emails to send the email when the UX is submitted.
5. Finally, because I want this to take place transparently to the user, I hid the List control and both Textbox controls.
I've attached a UX component which will demonstrate this although the List is based on Static Text rather than a SQL back end. Still it demonstrates the principle.
Since it is static data, you can simulate the SQL Group filter by changing the [,,0] option. [,,1] would return Group2.
There are probably other ways to approach this I'm sure, but I struggled to make this work so I thought I'd post this and hopefully it will benefit someone else down the road.
Stephen
The email users were basically hard coded into the javascript but I wanted to create a database table that would have the user emails that I wanted TO and CC based on a Group filter instead giving greater flexibility.
So, I created a SQL table EmailGroups that would hold EmailID, EmailGroup, EmailTo, and EmailCC.
PROBLEM
I had no way to link the EmailID to the current table in the UX in any meaningful way.
SOLUTION
Here is a method I ended up using to get a list of user emails from a SQL table.
1. Added a List component (MailList) to the UX which was based on the SQL table and filtered using a where clause to return only EmailTo and EmailCC users from a particular EmailGroup.
2. Added 2 textbox controls to the UX (EmailTo and EmailCC).
3. Used an event (could be a button click or onchange event, etc.) to trigger the following javascript which will populate the EmailTo and EmailCC fields from the SQL filtered List control.
This was done using the {dialog.object}.listGetValue() and {dialog.Object}.setValue() events like this:
Code:
//Read value in 'MAILTO' field from 'MAILLIST' and put it into MailTo textbox in UX. var lmailto = {dialog.object}.listGetValue('MailList','EmailTo',0); {dialog.Object}.setValue('MailTo',lmailto); //Read value in 'MAILCC' field from 'MAILLIST' and put it into MailCC textbox in UX. var lmailcc = {dialog.object}.listGetValue('MailList','EmailCC',0); {dialog.Object}.setValue('MailCC',lmailcc);
4. Used {EmailTo} and {EmailCC} placeholders instead of hard coded user emails to send the email when the UX is submitted.
5. Finally, because I want this to take place transparently to the user, I hid the List control and both Textbox controls.
I've attached a UX component which will demonstrate this although the List is based on Static Text rather than a SQL back end. Still it demonstrates the principle.
Since it is static data, you can simulate the SQL Group filter by changing the [,,0] option. [,,1] would return Group2.
There are probably other ways to approach this I'm sure, but I struggled to make this work so I thought I'd post this and hopefully it will benefit someone else down the road.
Stephen
Comment