- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-23-2017 05:03 AM
My requirement is to redisplay available actions based on the value in "work unit type" - when that value changes, new actions associated with it need to appear. A UI Macro I have developed takes care of this "redisplay:". This needs to happen before the record with that work unit type is created, therefore server-side code doesn't help me.
Therefore I created a onChange client script (executes onChange of work unit type) with the following code. What's in bold red calls a function in a UI Macro:
function onChange(control, oldValue, newValue, isLoading, isTemplate) {
if (newValue === '') {
// don't show the Work Unit Type Actions form section if work unit type is not yet filled in
g_form.setSectionDisplay('work_unittypeactions', false);
} else if (g_form.isNewRecord()) {
// when the record hasn't been saved yet, and the work unit type changes, we need to wipe out
// any work unit type actions that may have been selected and saved, and present the actions
// associated with the new work unit type.
getWut();
} // no "else" needed because work unit type is always protected after creation - there is no other way the work unit type can be changed.
}
Function getWut exists in a UI Macro (a copy of its entire xml):
<?xml version="1.0" encoding="utf-8" ?>
<j:jelly trim="false" xmlns:j="jelly:core" xmlns:g="glide" xmlns:j2="null" xmlns:g2="null">
<!-- New Records do not have an established work unit type, only existing records do -->
<g2:evaluate>
var isNotNewRecord = !current.isNewRecord();
// gs.info('MACRO-work_unit_type_actions: isNotNewRecord={0}",isNotNewRecord);
</g2:evaluate>
<!-- If the record is not new, allow the work unit type actions to show on the form.
The sys-id of the task group is included
to be used for retrieval of work unit type actions
and other needed data within the body and for processing -->
<j2:if test="$[isNotNewRecord]">
<tr>
<td colspan="2" width="100%" style="padding: 0;">
<g2:evaluate var="jvar_sysid">
var sysId = current.sys_id;
sysId;
// gs.info('MACRO-work_unit_type_actions: sysId={0}",sysId);
</g2:evaluate>
<g:work_unit_type_actions_body />
</td>
</tr>
</j2:if>
<j2:if test="$[!isNotNewRecord]">
<tr>
<td colspan="2" width="100%" style="padding: 0;">
<script>
// called from client script to make new work unit type available
function getWut(){
var myWut = g_form.getValue('work_unit_type');
alert('MACRO-work_unit_type_actions: myWut=' + myWut);
}
</script>
<g:work_unit_type_actions_body />
</td>
</tr>
</j2:if>
</j:jelly>
I have inserted gs.info statements in the work_unit_type_actions_body ui macro that is executed from the above ui macro (and after the getWut function). The alert appears when I change the value of work unit type on the form (and I do see that myWut has the value I need), and those gs.info statements in work_unit_type_actions_body do indeed write to the log, so I know that it is at least executing. But for the life of me I can't figure out how to extract the value in myWut and get it to ui macro work_unit_type_actions_body.
I have asked a similar question in Passing the value from client script to UI Macro, for your reference. This sounds like a similar issue, but how exactly it's done is not explained there.
Note - this is part of a scoped app - i have intentionally removed the scoped app parts of the macro name in the above example.
Thanks!
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-06-2017 09:54 AM
All,
We've assumed, based on Chris' and Slava's answers, that what we're trying to do won't work.
We were trying to do something fancy by having a change on a form's field trigger angular code to display data related to what that field was changed to. We've instead replaced this angular functionality with a simple glidelist, which provides for our requirement.
Thanks everyone.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-06-2017 09:54 AM
All,
We've assumed, based on Chris' and Slava's answers, that what we're trying to do won't work.
We were trying to do something fancy by having a change on a form's field trigger angular code to display data related to what that field was changed to. We've instead replaced this angular functionality with a simple glidelist, which provides for our requirement.
Thanks everyone.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-12-2017 12:48 PM
Hi Tor,
I have actually made it work.
Please check the thread below.
display a table values based on a value in catalog item in ui macro
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-13-2017 06:51 AM
Arka,
Looks promising. Thanks for sharing. Although we satisfied our requirement by using the simple glidelist instead, I'm almost certain this will come in handy for future requirements where we want to start taking advantage of what angular provides.
Rgds,
Tor
