
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-27-2017 03:43 AM
Hello Experts,
I am using Macro variable in that i am using widget:
Here is my code:
HTML:
<div class="input-group ">
<input type="text" name="name" ng-model="c.data.inputValue" />
<button type="button" class="btn btn-danger btn-block" ng-click="c.setFieldValue()">Value</button>
</div>
Client Controller:
function($scope) {
var c = this;
c.setFieldValue = function() {
c.server.update().then(function(response) {
c.data = {};
var g_form = $scope.page.g_form;
var values = [];
values = g_form.getValue('a2');
var disp = [];
disp = g_form.getDisplayValue('a2');
if(!values){
g_form.setValue('a2', $scope.data.sysID, $scope.data.text);
}else{
g_form.setValue('a2', $scope.data.sysID+','+values, $scope.data.text+','+disp);
}
});
Server Side:
(function() {
if(!input)
return;
var bTab = new GlideRecord('u_backend_table');
bTab.initialize();
bTab.u_text = input.inputValue;
bTab.u_text1 = // I want to use Variable value
data.sysID = bTab.insert();
data.text = input.inputValue;
})();
I unable to get the Variable value at above highlighted region.
FYI: i also tried with
$sp.getValue('variable_name');
$sp.getDisplayValue('variable_name');
Nothing worked
Solved! Go to Solution.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-30-2017 11:50 PM
Hi Azeez,
Try below code.
Client Controller:
function($scope) {
var c = this;
c.setFieldValue = function() {
c.data.var1 = g_form.getDisplayValue('variable_name');
c.server.update().then(function(response) {
c.data = {};
var g_form = $scope.page.g_form;
var values = [];
values = g_form.getValue('a2');
var disp = [];
disp = g_form.getDisplayValue('a2');
if(!values){
g_form.setValue('a2', $scope.data.sysID, $scope.data.text);
}else{
g_form.setValue('a2', $scope.data.sysID+','+values, $scope.data.text+','+disp);
}
});
}
}
Server Side:
(function() {
if(!input)
return;
var bTab = new GlideRecord('u_backend_table');
bTab.initialize();
bTab.u_text = input.inputValue;
bTab.u_text1 = input.var1;// I want to use Variable value
data.sysID = bTab.insert();
data.text = input.inputValue;
})();
Thanks,
Srikanth
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-27-2017 05:53 AM
Hi Abdul,
You can give input tag to receive your input and save that data using ng-model tag like this ng-model='c.data.var_name'. then use input.var_name in server script. This should help you.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-27-2017 06:03 AM

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-28-2017 02:13 AM
Thank you Ajay let me go thorough this and will let you know if i have any issues
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-28-2017 02:25 AM
Hi Abdul,
Sure. Let me know if that helps you.