- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎09-11-2017 01:10 AM
Hello.
In order to simplify my question I've created a new ui macro variable that contain only a single input field:
<?xml version="1.0" encoding="utf-8" ?>
<j:jelly trim="false" xmlns:j="jelly:core" xmlns:g="glide" xmlns:j2="null" xmlns:g2="null">
<input type="text" id="test" name="test"></input>
</j:jelly>
In order to view the variable the catalog form I've connected a new widget to the macro variable that contain the same field:
Body HTML template:
<div>
<input type="text" id="test" name="test" />
</div>
And indeed the new variable is shown on the catalog form as input field in the new service portal, but when i submit the catalog with some string inside the input field the variable value stay empty:
I tried several methods in order to set the value in the variable but unfortunately i didn't succeed. my only concern is how to set the value in the widget, not in the macro.
Thank you/
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎09-12-2017 04:33 AM
Hi
Values entered in widget variables are NOT saved when you submit the item.
You need to add additional regular variables (eg. a single line text) and then on an onSubmit script (only for ui macros on the old service catalog) copy the value from your widget to the regular variable. You can hide the regular variable using a UI policy.
Making your own widget for SP, you will not be able to access the content with an onSubmit script, as you can't accces the DOM. Instead you build an onChange logic into your widget to copy the value from the input field to your regular variable everytime a change happens.
You can access variables on the catalog item from the widget via:
$scope.page.g_form.setValue('var_name');
Also see how to monitor for changes in catalog variables here: Embedding widgets in Service Catalog - ServicePortal.io - Service Portal, CMS, and Custom Apps
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎09-12-2017 04:33 AM
Hi
Values entered in widget variables are NOT saved when you submit the item.
You need to add additional regular variables (eg. a single line text) and then on an onSubmit script (only for ui macros on the old service catalog) copy the value from your widget to the regular variable. You can hide the regular variable using a UI policy.
Making your own widget for SP, you will not be able to access the content with an onSubmit script, as you can't accces the DOM. Instead you build an onChange logic into your widget to copy the value from the input field to your regular variable everytime a change happens.
You can access variables on the catalog item from the widget via:
$scope.page.g_form.setValue('var_name');
Also see how to monitor for changes in catalog variables here: Embedding widgets in Service Catalog - ServicePortal.io - Service Portal, CMS, and Custom Apps
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎09-14-2017 02:25 AM
Great answer.
The command : $scope.page.g_form.setValue('var_name'); that's what i looked for.
Thank you.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎10-11-2017 05:38 AM
Hi Lars,
The above command doesn't work for me. I get this error when i try to set the variable value from widget. "TypeError: Cannot read property 'setValue' of undefined". I am working on Helsinki patch 11. Can you help me?
regards,
Divya Lakshmi.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎10-11-2017 05:59 AM
Is $scope declared as a service in the client script function?
function($scope) {
/* widget controller */
var c = this;
.
.
.
}