How to include hyperlink in check box variable

Rani11
Tera Expert

Hi All,

I have a requirement to include hyperlink in check box variable. But by default we does not have any "Annotation" tab in check box variable. How do we achieve this by any chance. Please help me to get a solution on the same.

In the highlighted area hyperlink should come named as "Link" example: I Acknowledge Link(https://google.com) the content.

find_real_file.png

1 ACCEPTED SOLUTION

You have to do the validation inside the widget only .

You have to use the ng-model for it and then use client script(widget to set the value to some variable in your form)

HTML

<div>

<input type="checkbox" ng-change = 'c.checkboxcheck()'ng-model='data.check'>I Acknowledge <a href="https://www.google.com" target="_blank" rel="noopener">Link Opens in New Tab</a>Test Record <a href="https://www.w3schools.com" target="_blank" rel="noopener">Link Opens</a><br>

</div>

 

Client Code

 

//make sure you add $scope to function



var g_form = $scope.page.g_form;
c.checkboxcheck = function(){

g_form.setValue('variable name',c.data.check);

}

 

 

Now you can check this in your client script

 

var costcenter = g_form.getValue('cost_center');
alert(costcenter);
var ack = g_form.getValue('variable name');
alert(ack);
if(costcenter=='d9d0a971c0a80a641c20b13d99a48576' && !ack ){
g_form.addErrorMessage('please enter acknowledgement');
return false;
}
else{
return true;
}

 

 

I haven't tested the above but this is the way you have to follow, let me know if you have any questions.

View solution in original post

11 REPLIES 11

kushal2
Kilo Contributor

Hi Rani, I am in same situation. Can you tell me where we should write client controller exactly?

Ankur Bawiskar
Tera Patron
Tera Patron

Hi,

It is not possible out of the box

You can achieve this using UI macro and Widget

refer below link where I have show how to add URL; on similar lines you can implement

Need to implement catalog URL Macro with the help of Jelly script

Regards
Ankur

Regards,
Ankur
✨ Certified Technical Architect  ||  ✨ 9x ServiceNow MVP  ||  ✨ ServiceNow Community Leader