Important Update: Archer Community Scheduled Maintenance on November 23–24 - New Community Launching Soon! Learn More..

cancel
Showing results for 
Search instead for 
Did you mean: 

Hide custom button based on record status

cpallone
Contributor

I have a custom button that is created and used to set a field in the record. The button is displayed next to the save and close button. I'm trying to hide this button (or only show it) if a field contains a certain value.

My code to create the button (this works perfectly):

<div class="toolbar-app-buttons-left">

<a title="Set Value" class="tb-btn-link-left" id="btnSetValue" href="javascript&colon;void(0);" data-check-dirty="false">

<div class="tb-btn">RE-OPEN</div>

</a>

</div>

<script type="text/javascript">

var integration = {

statusFieldId:"28451",

statusSubmit:"90422"

};

$("#btnSetValue").insertAfter('#master_btnSave1');

$('#btnSetValue').click(function(){

UpdateValuesList(integration.statusFieldId, integration.statusSubmit);

$("#master_btnApply").click();
});

function UpdateValuesList(changeId, assignedValue) {

var valueArray = new Array(1);

valueArray[0] = assignedValue;

$CM.setFieldValue(changeId, valueArray, '');

}

</script>

My code to hide the button if the status is 1 of 3 values (this is not working):

<script type="text/javascript">

var valuesListFieldId = 28426;
var valuesListValueId = 90397;
var valuesListValueAId = 90399;
var valuesListValueCId = 90400;
var valuesListValue;

Sys.Application.add_load( function() {
valuesListValue=$('div[id*="f' + valuesListFieldId +'c"] div:last').attr('data-valueslistvalueid');

if(valuesListValue == valuesListValueId || valuesListValue == valuesListValueAId || valuesListValue == valuesListValueBId || valuesListValue == valuesListValueCId) {
$('#btnSetValue').hide();
});

</script>

1 ACCEPTED SOLUTION

Accepted Solutions

Fard.Thomas
Archer Employee
Archer Employee

Hi Christina,

Please give this script a try and let me know if you encounter any issues.

View solution in original post

1 REPLY 1

Fard.Thomas
Archer Employee
Archer Employee

Hi Christina,

Please give this script a try and let me know if you encounter any issues.