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

Pranav Bhagat
Kilo Sage

I don't think you can do it with OOB variables

 

Try using Macro variable and create a widget like below example

1. Create a simple widget : Disclaimer with below snippet in body html.

<div>
<input type="checkbox">Your Text <a href="www.google.com">www.google.com</a><br>
</div>

2. Create a variable of type Macro(Set the widget ) & save it.

Hi Pranav, 

Its working but its not working when I try to make validation for that checkbox, if its not checked.

Variable Created as "Macro"

Created Widget and attached in macro variable.

Widget :

<div>

<input type="checkbox">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>

Trying to restrict onsubmit of the request when this check box is blank. I have tried it via client script but it always shows the value as empty.

Tried below Client Script for validation onsubmit but it does not works:

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

How to set value and how to make validation for that macro variable?

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.

Hi Pranav,

I have tried the about codes but no luck. Its not showing error message when checkbox is not checked.