Important Update: Community URLs redirect issues are partially resolved. Learn More. .

cancel
Showing results for 
Search instead for 
Did you mean: 

How to make Custom Object Button Change Value in Values List

AmyJoJarboe
Contributor III

Hello All,

I'm still very new to Archer, but I'm trying to make a Custom Object Button that will change a value in a values list. I've seen a lot of samples, but they don't make much sense. Can someone please break this down very simply for me? I can create a button, I'm just really struggling on creating JavaScript that works to change a value in a values list.

Thank you!

25 REPLIES 25

The field is public and active - it's also a Values Popup control if that helps!

Code:

<div class="toolbar-app-buttons-left">
   <a title="Set Value" class="tb-btn-link-left" id="btnSetValue" href="javascript:void(0);" data-check-dirty="false">
      <div class="tb-btn" data-icon="&#xE348" data-icon-pos="left">Submit</div>
   </a>
</div>

<script type="text/javascript">
   var integration = {
   statusFieldId:"18925",
   statusSubmit:"81935"
};

$('#btnSetValue').click(function(){
   UpdatesValueList(integration.statusFieldId, integration.statusSubmit);
});

function UpdatesValueList(changeId, assignedValue) {
   var valueArray = new Array(1);
   valueArray[0] = assignedValue;
   $CM.setFieldValue(changeId, valueArray, '');
}
</script>

I think this is a bug in one of the JavaScript functions, and as far as I can tell, it only affects values popups. If you change your field to a drop down list, the code should work.

 

When you call $CM.setFieldValues, it eventually calls another function called set_selectedValues to actually set the value. If the field is a values popup, set_selectedValues calls $CM.getValuesListByFieldId and tries to read the "values" property from the returned object. However, $CM.getValuesListByFieldId seems to return undefined for any VL (at least the ones I tried it with), so there's no "values" property to read. That's why your JS console shows the "Cannot read property 'values' of undefined" error.

 

For a drop down list, set_selectedValues doesn't call $CM.getValuesListByFieldId, so drop down lists bypass the bug.

It worked!!!!! You are all AMAZING, thank you so much! 

I completely forgot about that annoying bug ;)

 Advisory Consultant

AdityaPavanNet1
Contributor

David Petty

 

I am facing the similar issue. Below is my code and I couldn't update the values for my dropdown Values list field which is public onlayout.

 

<div class="toolbar-app-buttons-left">
<a title="Initiate Renewal" class="tb-btn-link-left" id="btnSetValue" href="javascript:void(0);" data-check-dirty="false">
<div class="tb-btn" data-icon="&#xE348" data-icon-pos="left">Initiate Renewal</div>
</a>
</div>

<div class="toolbar-app-buttons-right">
<a title="Initiate Closure" class="tb-btn-link-right" id="btnSetValue" href="javascript:void(0);" data-check-dirty="false">
<div class="tb-btn" data-icon="&#xE348" data-icon-pos="right">Initiate Closure</div>
</a>
</div>

<script type="text/javascript">
var integration = {
fieldID:"24003",
valueID:"76369"
};

$('#btnSetValue').click(function(){
UpdatesValueList(integration.fieldID, integration.valueID);
});

function UpdatesValueList(changeId, assignedValue) {
var valueArray = new Array(1);
valueArray[0] = assignedValue;
$CM.setFieldValues(changeId, valueArray, '');
}
</script>

 

 

 

Can someone help me which this. I have a requirement where Users wants to renew a record by clicking button and we have flag field which has two values "Yes, No". Once user clicks on renew button then the flag should be automatically set to "Yes" and a correspondent A2A data feed will be ran based on the schedule.

Aditya, we are already discussing this via IM….

 Advisory Consultant