I have a record producer and want to show variables in portal Level by using Widget?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-14-2022 07:57 AM
I created a Record Producer and also created a widget . When category changes then a form will pop up.
I want to show another two variables and pass their values in the Portal level by using widget based on logged in user role .
so need help on that like how to write server script and also Client controler script in that widget.
Based on Category selection i need to show this two variables with their values in portal.
Name - u_name (Default value : gs.getUserID();)
Email - u_email (Default value : Loged in user email )
Widget : Server Script :
var mdmform=new global.GSC_MDM_Form_Utils();
var query="";
//===========================================================
logic here for show variables based on logged in user role:
//============================================================
if(input.action == "check_category"){
data.fields=[];
if(input.showForm)
query="u_sub_type=form_hub_one^u_box_genaral=true";
else if(input.showFormTwo)
query="u_sub_type=form_hub_two^u_box_genaral=true";
data.fields=mdform.getFields(query,input.variables);
//gs.addInfoMessage(JSON.stringify(data.fields))
}
Widget : Client Controller Script :
api.controller = function($rootScope, $scope) {
/* widget controller */
var c = this;
c.data.showForm = false;
c.data.showFormTwo = false;
c.data.variables = {};
c.data.datepicker = "";
$scope.min = new Date();
$rootScope.$on("field.change", function(evt, parms) {
var field = parms.field.name;
var value = parms.field.value;
if (field == 'u_category') {
c.data.showForm = c.data.form_hub_one.indexOf(value) >= 0;
c.data.showFormTwo = c.data.form_hub_two.indexOf(value) >= 0;
if (c.data.showForm) {
$rootScope.$broadcast("has_md", true);
$scope.page.g_form.setValue('u_md_form_hub_one', '{}');
c.data.variables.account = $scope.page.g_form.getValue('account');
c.data.variables.u_category = value;
c.data.action = "check_category;
c.server.update().then(function(resp) {
c.data.action = "";
$scope.updateFields();
$scope.checkField();
});
} else if (c.data.showFormTwo) {
$rootScope.$broadcast("has_md", true);
$scope.page.g_form.setValue('u_md_form_hub_two', '{}');
c.data.variables.account = $scope.page.g_form.getValue('account');
c.data.variables.u_category = value;
c.data.action = "check_category";
c.server.update().then(function(resp) {
c.data.action = "";
$scope.updateFields();
$scope.checkField();
});
} else {
$rootScope.$broadcast("has_md", false);
c.data.fields = [];
$scope.page.g_form.setValue('u_md_form_hub_one', '');
$scope.page.g_form.setValue('u_md_form_hub_two', '');
}
}
});
- Labels:
-
Change Management
-
Service Catalog
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-14-2022 08:34 AM
Dear SUBHASHIS,
service portal Refere this link which help to get this requirment eassly.
Link : https://serviceportal.io/docs/documentation/widget_server_script_apis.md
If it's working for you then please correct and make as helpful.