Important Update: Community URLs redirect issues are partially resolved. Learn More. .
2020-08-05 11:38 AM
Hi ,
I am trying to run the below code to compare to GVL in a Questionaire but unfortunately it is not working .Can anybody help me out here Ilya Khen
<script type="text/javascript">
var primary = 81709;
var secondary = 154;
Sys.Application.add_load(function() {
$('#master_btnSave').clone().attr('id', 'master_customBtnSave').insertBefore('#master_btnSave');
$('#master_btnSave').hide();
$('#master_customBtnSave').unbind('click').prop("onclick", null).click(function(){ validation('save');return false;});
$('#master_btnApply').clone().attr('id', 'master_customBtnApply').insertBefore('#master_btnApply');
$('#master_btnApply').hide();
$('#master_customBtnApply').unbind('click').prop("onclick", null).click(function(){ validation('apply');return false;});
});
function validation(action){
if($('div[id*="f'+primary+ 'c"]').text().trim() == $('div[id*="f'+secondary+ 'c"]').text().trim())
{
var msg = '[Scores need to be cleared before you save this value]';
var title = 'Required Field';
Alert(msg,title);
return;
}
if(action=='save'){
$('#master_btnSave').click();
}
else if(action=='apply'){
$('#master_btnApply').click();
}
}
</script>
2020-08-05 12:07 PM
If you use the same GVL for both VL fields, then:
<script type="text/javascript">
var primary = 81709;
var secondary = 154;
Sys.Application.add_load(function() {
$('#master_btnSave').clone().attr('id', 'master_customBtnSave').insertBefore('#master_btnSave');
$('#master_btnSave').hide();
$('#master_customBtnSave').unbind('click').prop("onclick", null).click(function() {
validation('save');
return false;
});
$('#master_btnApply').clone().attr('id', 'master_customBtnApply').insertBefore('#master_btnApply');
$('#master_btnApply').hide();
$('#master_customBtnApply').unbind('click').prop("onclick", null).click(function() {
validation('apply');
return false;
});
});
function validation(action)
{
var primaryValue = $CM.getFieldValue(primary);
var secondaryValue = $CM.getFieldValue(secondary);
primaryValue = primaryValue == null ? "" : primaryValue.toString();
secondaryValue = secondaryValue == null ? "" : secondaryValue.toString();
if (primaryValue == secondaryValue) {
var msg = '[Scores need to be cleared before you save this value]';
var title = 'Required Field';
alert(msg, title);
return;
}
if (action == 'save') {
$('#master_btnSave').click();
} else if (action == 'apply') {
$('#master_btnApply').click();
}
}
</script>
2020-08-05 12:55 PM
Hi IIya, Thanks for your immediate response
It is Two different Value lists which contains two different GVL.. One value list contains -- yes or no and the other value list contains status. It would also be helpful if I can get a code for comparing Calculated field to one GVL where calc field populates numeric value . Thanks again for your help :-)
2020-08-05 01:07 PM
I am not sure, how you going to compare Status to Yes/No, as it always gonna be different.
2020-08-05 01:21 PM
ok we can ignore the Yes/no requirement then .. The other requirement is Comparing Cal Field i.e if it contains value(numeric) and the status(value list) contains "review not required". Then we need to get a Popup message saying Review not required cannot be selected as Numeric value is populated in the calculated field. Thank you
2020-08-05 01:25 PM
Calc Field is a Text Field I assume. Then it can be taken only over JQuery element pointer for example.
E.g. David Petty explained TextField - Read failing in custom objects using getFieldValue() function.
2020-08-05 01:37 PM
Apologies for bothering you with too many questions. The calc field is a numeric field
2020-08-05 01:46 PM
Yes, essentially same. Over JS or JQuery.