Important Update: Archer Community Scheduled Maintenance on November 23–24 - New Community Launching Soon! Learn More..
2018-08-01 02:02 AM
Hello Team,
I need your help to on below mentioned scenario.
I want to hide COPY button when value list option A ,B,C or D selected.
For other options COPY button should be there.
I have written below code:
<script type="text/javascript">
var valuesListFieldId = 22875; // This is the field id of the values list
var valuesListValueId = 77972; // This is the id of the value to check against
var valuesListValueId = 77973; // This is the id of the value to check against
var valuesListValueId = 77971; // This is the id of the value to check against
var valuesListValueId = 77970; // This is the id of the value to check against
var valuesListValue;
Sys.Application.add_load( function() {
valuesListValue=$('div[id*="f' + valuesListFieldId +'c"] div:last').attr('data-valueslistvalueid');
if(valuesListValue == valuesListValueId) {
$('#master_btnCopy').hide();
}
});
</script>
But this code is only working when 'var valuesListValueId = 77970; ' only option D is getting selected.
For other selection, COPY is enabled.
2018-08-01 04:22 AM
Try this one. A bit dirty, and better to use loo/break structure:
var valuesListFieldId = 22875; // This is the field id of the values list
var valuesListValueAId = 77972; // This is the id of the value to check against
var valuesListValueBId = 77973; // This is the id of the value to check against
var valuesListValueCId = 77971; // This is the id of the value to check against
var valuesListValueDId = 77970; // This is the id of the value to check against
var valuesListValue;
Sys.Application.add_load(function() {
valuesListValue = $('div[id*="f' + valuesListFieldId + 'c"] div:last').attr('data-valueslistvalueid');
if (valuesListValue == valuesListValueAId || valuesListValue == valuesListValueBId || valuesListValue == valuesListValueCId || valuesListValue == valuesListValueDId) {
$('#master_btnCopy').hide();
}
});
Code above would work in case you use Dropdown type of VL, plus during the record load only, not when VL is changed.
2018-08-01 01:57 PM
In this part of the code:
var valuesListValueId = 77972;
var valuesListValueId = 77973;
var valuesListValueId = 77971;
var valuesListValueId = 77970;
... You're using the same variable name each time, so the variable is set to the value in the last statement (77970). This is why it works with D but not the others. You would need to use different variable names, or an array with a loop.
2018-08-01 02:32 PM
Good catch Geoff
Prathamesh see how this work.
<script type="text/javascript">
var valuesListFieldId = [22875,77972,77973,77971,77970];
Sys.Application.add_load( function() {
for(var v=0; v<valuesListFieldId.length; ++v){
if($CM_getFieldValue(valuesListFieldId[v]) != null) { // Looking to see if the values list value isn't null
$('#master_btnCopy').hide();
break;
}
}
});
</script>
Advisory Consultant
2018-08-01 02:38 PM
That is what I call - quality code Thanks, David!
2018-08-21 07:55 AM
This is only working when record is in view mode. Upon editing the record, copy button is coming back. Same in 5.5 or in 6.3. Any Idea to fix it. David's below code is not working.
2018-08-21 08:03 AM
Chatterjee, do you have the Display option for the custom object set to Both?
Advisory Consultant
2018-08-21 08:06 AM
David's code should work for sure as it it getting values from internal library.
2018-08-21 08:20 AM
Yes David. Display option is set to Both.
2018-08-21 08:22 AM
Can you post the code you're using in the custom object?
Advisory Consultant