- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-24-2022 10:35 AM
Hi ,
I like to generate a dynamic URL based on the user selected on catalog form, hence client controller script should be triggered onChange as well.
I am using widget as custom variable.
Widget defination
HMTL Body template
<div>
<!-- your widget template -->
<a>In alignment with {{c.data.requested_for}} I accept the processing of order</a>
</div>
Server script
(function() {
/* populate the 'data' object */
/* e.g., data.table = $sp.getValue('table'); */
var gr = new GlideRecord("sys_user");
gr.addQuery("sys_id", input.message);
gr.query();
if (gr.next()) {
data.requested_for = gr.first_name;
}
})();
function($scope) {
/* widget controller */
var c = this;
var g_form = $scope.page.g_form;
$scope.$watch(function () {
return $scope.page.g_form.getValue('requested_for');
}, function (value) {
c.data.message = value;
c.server.update().then(function(response){
});
});
}
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-25-2022 02:03 AM
Replace {{c.data.requested_for}} with {{data.requested_for}}
Replace gr.first_name with gr.getValue('first_name');
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-25-2022 02:03 AM
Replace {{c.data.requested_for}} with {{data.requested_for}}
Replace gr.first_name with gr.getValue('first_name');
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-25-2022 02:54 AM
Many thank, it did work. the only answer I am looking at - how this can be made dynamic when the request for user is changed. I other word the client script should be called on 'onChange' event as well.