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

cancel
Showing results for 
Search instead for 
Did you mean: 

Custom Object to copy a calculated values list field

SidathPeriyasa2
Contributor II

I have the following custom object snippet. The objective is to copy the value of a text, values list and numeric calculated fields in addition to a user/group field. It appears to work for a text field but not for the others. Any help will be appreciated.

 

<div style="text-align:center;">
<img src="../BackgroundImageGenerator.axd?className=StyledButton&classProperties=caption:Populate Details;iconSetStyle:VistaRound;baseColor:%23DDDDDD;disabled:False" onclick="sendRequest()"></div> 
<script type="text/javascript">
var apmID=21794,desc=21681,test=22012,test1=22013;

function sendRequest() 
{

 

alert("Hi");
var y=document.getElementById("master_DefaultContent_rts_s7900_f21794c").textContent;
alert(y);
document.getElementById("master_DefaultContent_rts_s7900_f21680c").value=y;
$("#master_DefaultContent_rts_s7900_f21680c").focus();

alert("Hi");
y=document.getElementById("master_DefaultContent_rts_s7900_f21681c").textContent;
alert(y);
document.getElementById("master_DefaultContent_rts_s7900_f22011c_text").value=y;
$("#master_DefaultContent_rts_s7900_f22011c_text").focus(); 

 

alert("Hi");
y=document.getElementById("master_DefaultContent_rts_s7931_f22023c").textContent;
alert(y);
document.getElementsByName("master$DefaultContent$rts$s7931$f22024cdp")[0].value=y;

 

alert("Hi");
y=document.getElementsByName("master$DefaultContent$rts$s7900$ctl20")[0].value;
alert(y);
ValuesChange(test1, y);

}
function ValuesChange(changeId, assignedValue) 
{
alert(changeId);
alert(assignedValue);
var valueArray = new Array(1);
valueArray[0] = assignedValue;
valueArray[1] = "0"
ArcherTech.UI.GenericContent.GetInstance().setFieldValue(changeId, valueArray, '');
$("#master$DefaultContent$rts$s7900$ctl20").focus();
}
</script>

10 REPLIES 10

DavidPetty
Archer Employee
Archer Employee

You can use $CM.getFieldValue([field id]); (only works in edit mode) to get the values of the text, numeric, and values list (note only returns the value id).

 

For a users/groups, record permissions field use,

$.parseJSON($('input[id*="f1234c_shf"]').val();

It will return an array being the values for a users/groups, record permission field are stored as JSON.

 Advisory Consultant

Thanks David! So it is not possible to extract the textual value of the values list to set to another field?

You still can using,

$.parseJSON($('input[id*="f1234c"]').val();

It will return an array of the value.

 Advisory Consultant

Thanks again David! Can we use custom objects with a mix of jQuery and JavaScript? Also, another issue with the above JS is that we are unable to set the value in the values list field. An error is being encountered in setFieldValue. Do you see anything that we are missing or would it not apply to values list field types? 

Here is a JS code for setting the Values list field.

 

function setValuelist(changeid,assignedvalue)
{
var valuearray= new Array(1);
valuearray[0]=assignedvalue;
ArcherTech.UI.GenericContent.GetInstance().setFieldValue(changeid,valuearray,'');
}‍‍‍‍‍‍

Call this function as: 

setValuelist(Field_id,Value_id)‍‍;

Sure can,  jQuery is a framework that sits on top of JavaScript.

 Advisory Consultant

Thanks Arun! The logic in this function is the same as what we have. We tried your code as well but no success. Although one thing I would like to point out is that it works on 6.5 and not on 6.4 P2 which is our target version.

Any JavaScript errors being reporting in the console when setting the value?

 Advisory Consultant

For some reason, we are not seeing any messages in the console. The code executes without issues but a blank value is being set in the values list field. Wondering if this has something to do with the 6.4 P2 version.

 

We are considering to rework the custom object. The goal is to copy a record and have a custom object remove the cross reference. At this point there is only one xref. If you have previously developed one for this scenario and willing to share that would be appreciated. Thanks!