g_form.addErrorMessage syntax is not working in client controller catalog item

String
Kilo Sage

Hi Team ,

am trying to print the error message in the portal using widget ,but not getting the error

Screenshot 2023-03-15 at 8.39.54 PM.png

 

Please help me wright syntax 

1 ACCEPTED SOLUTION

Prince Arora
Tera Sage
Tera Sage

@String , 

 

Could you please try this:

 


api.controller=function($scope,spUtil) {
/* widget controller */
var c = this;

$scope.myFunc = function(){
spUtil.addInfoMessage("There has been an error processing your request")
}

 

 

PRINCE_ARORA_0-1678897181791.png

 

If my answer solved your issue, please mark my answer as Correct & 👍Helpful based on the Impact.

View solution in original post

9 REPLIES 9

priyasunku
Kilo Sage

Hi @String 

 

please check the below link it might help you.

 

https://www.servicenowelite.com/blog/2019/7/31/widgets-in-catalog-items

 

 

If my answer solved your issue, please mark my answer as Correct & 👍Helpful

Prince Arora
Tera Sage
Tera Sage

@String , 

 

Could you please try this:

 


api.controller=function($scope,spUtil) {
/* widget controller */
var c = this;

$scope.myFunc = function(){
spUtil.addInfoMessage("There has been an error processing your request")
}

 

 

PRINCE_ARORA_0-1678897181791.png

 

If my answer solved your issue, please mark my answer as Correct & 👍Helpful based on the Impact.

Hi @Prince Arora 

am using the below code 

 

api.controller = function($scope, spUtil) {
/* widget controller */
var c = this;
$scope.clickMethod = function() {

var inputs = {

"shipto": $scope.page.g_form.getValue('shipto'),
"billto": $scope.page.g_form.getValue('billto'),
"mrvs": JSON.parse($scope.page.g_form.getValue("IO:6390228f1b306d1009952f02604bcb2b")),
"asset": $scope.page.g_form.getValue('asset')
};
//$scope.page.g_form.getValue("IO:3D1bf06ecb1b306d1009952f02604bcbb6");

c.server.get(inputs).then(function(resp) {
alert(resp.data.result);

($scope.page.g_form.setValue("IO:6390228f1b306d1009952f02604bcb2b", resp.data.result));

alert('total amount' + ". " + resp.data.amount);

if (resp.data.amount != null) {
alert('total amount if');
$scope.page.g_form.setValue('u_total_amount', resp.data.amount);
} else {

alert('total amount else 12345');
$scope.myFunc = function() {
spUtil.addInfoMessage("There has been an error processing your request");
};

}

});

};

};

 

code is going to else block and can see the alert  total amount else 12345 but addinfoMessage is not coming

String_0-1678899822159.png

 

 

Please guide me 

@String ,

Your else should be like this:

else {
spUtil.addInfoMessage("There has been an error processing your request");
}

 

If my answer solved your issue, please mark my answer as Correct & 👍Helpful based on the Impact.