- Subscribe to RSS Feed
- Mark as New
- Mark as Read
- Bookmark
- Subscribe
- Printer Friendly Page
- Report Inappropriate Content
Included in the Developer Toolbox Update Set available on Share (link to Share in the post).
Another one of those lazy/productivity tools with a similar function:
This one really walks that fine line between laziness and productivity. 🙂
I like to name my Table Transform Maps the same as the import table name so it is easy to find and match them up, so I wrote a Related Link UI Action to insert the display name of the selected Source table into the Name field client-side.
I've been working on a lot of imports lately and got tired of entering the name time after time (lazy). The nice thing is the name will be exactly as I like it - the same as the name of the table (productive).
Here are the UI Action settings:
Name: Set Name from Source Table
Table: Table Transform Map [sys_transform_map]
Order: 100,000
Action name: u_fpc_set_name_from_source_table
Show insert: checked
Show update: checked
Client: checked
Form link: checked
Hint: Populate the Name field from the selected Source Table name (FPC)
Messages: u_fpc_set_name_from_source_table.name.format
u_fpc_set_name_from_source_table.confirm
u_fpc_set_name_from_source_table.error.source.table.empty
u_fpc_set_name_from_source_table.error.source.table.not.found
Onclick: uFpcSetNameFromSourceTable();
Condition: current.canWrite();
Script:
function uFpcSetNameFromSourceTable(){
//hide previous field messages
try {
g_form.hideFieldMsg("name", true);
} catch(err) {}
//make sure the control is on the form
var control = g_form.getControl("sys_transform_map.source_table");
if (control) {
//make sure something is selected
var sourceTable = g_form.getValue("source_table").trim();
if (sourceTable == "" || sourceTable == "-- None --") {
g_form.showFieldMsg("source_table", getMessage("u_fpc_set_name_from_source_table.error.source.table.empty"), "error");
return;
}
if (g_form.getValue("name").trim() != ""){
if (!confirm(getMessage("u_fpc_set_name_from_source_table.confirm")))
return;
}
var selected = control.selectedIndex;
var value = control.options[selected].value.toString();
var text = control.options[selected].text.toString();
var stripText = " [" + value + "]";
var nameFormat = getMessage("u_fpc_set_name_from_source_table.name.format");
g_form.setValue("name", nowapi.g_i18n.format(nameFormat, {0: text.replace(stripText, "")}));
} else {
g_form.addErrorMessage(getMessage("u_fpc_set_name_from_source_table.error.source.table.not.found"));
}
}
I've attached XML files for the UI Action and UI Message records if you want to import them. As always, try it out in your company's development instance first, or better yet, your own personal development instance.
NOTE: I've been doing some cleaning up lately, and as @jfarrer suggested to add an "Import" prefix to the name, the script has been updated to use a UI Messages as the basis for the name. It uses the "format(String message, Object map)" method to insert the name into the template you define in the "u_fpc_set_name_from_source_table.name.format" UI Message. At the very least, the UI Message must contain "{0}" in order to insert the name of the table into the string.
And because it is a UI Message, you can easily configure and use multilingual prefixes.
- 1,140 Views
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.