Important Update: Some Community URL Redirects are Under Maintenance. Learn More. .

cancel
Showing results for 
Search instead for 
Did you mean: 

Custom Object to Update Values List and Save 6.3 P5

NicholasPallard
Contributor II

We recently moved to version 6.3 P5 and one of our custom objects is no longer working.  The purpose of the custom object is to update a values list and then "Save" (previously "Apply").  We do not want to "Save and Close".  The issue in 6.3 is that the Save and Close button has returned and now the custom object closes the record instead of saving and staying on the page.  I have tried several methods posted by other users, but have not yet had any success in updating the values list and "Saving" instead of "Save and Close".  Any advice is greatly appreciated.  Below is the code we are using:

<script language="javascript">

 var integration = {

   fieldID:"11111", 

   valueID:"22222", 

 };    

function UpdateValueList(changeId, assignedValue) {

  var valueArray = new Array(1); 

  valueArray[0] = assignedValue; 

  ArcherTech.UI.GenericContent.GetInstance().setFieldValue(changeId, valueArray, ''); 

ShowAnimationAndPostback('master$btnSave')

}

</script>

<div style="text-align:center;">

<img src="../BackgroundImageGenerator.axd?className=StyledButton&classProperties=caption:Advance to Step 2 of 5;iconSetStyle:VistaRound;baseColor:%23276CA8;disabled:False" onclick="javascript:UpdateValueList(integration.fieldID,integration.valueID);"></div>

74 REPLIES 74

Thanks Ilya. I opened case number 01387827.

Jeff, I just tried the code in my 6.5 P5 environment and didn't have any of the issues you're seeing.  The record value gets updated, saved and dump back to the Record Browser.  No errors in the console and no Unsaved Changes warnings.

 Advisory Consultant

Thanks David.

 

I am at a real loss here. A colleague gave me a copy of the custom object javascript code that works for them on a 6.5 P2 environment, and it doesn't work for me (and I tried it on 6.2, 6.4, and 6.5 platforms). I've also tried different browsers (IE, Firefox, Chrome) and I always get the same error and behavior (the values list gets set to the value I want, the SCRIPT5007 ReadOnly error gets thrown, and because of the error the code quits and the save and close function is not executed).

 

If I remove the call to the function to update the values list ($CM.setFieldValue(changeId, valueArray, '');), the save and close function call executes successfully, so I know the issue is because of the SCRIPT5007 ReadOnly error.

 

The ODA application is titled "CustomButtonTest" (it is in Development status) and in the application the values list is set to Public. There are no DDEs, there is no workflow. The application consists of five fields. There is only a General Information section. Here are the 5 fields:

 

 

  1. First Published (off layout)
  2. Last Updated (off layout)
  3. Tracking ID (key field)
  4. Values list named "Status" with two values ("Submitted" and "In Process"). "Status" has an ID of 22595, and "Submitted" has an ID value of 75269. 
  5. Custom Object named "Button" with the following javascript code:

 

<script type="text/javascript">

 

var integration = {

statusFieldId:"22595",

statusSubmit:"75269"

};

 

function UpdateValueList(changeId, assignedValue) {

var valueArray = new Array(1);

valueArray[0] = assignedValue;

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

$('#master_btnSave').click(); }

 

</script>

 

<div style="text-align:center;"> <img id="btnSaveAsDraft" src="BackgroundImageGenerator.axd?className=StyledButton&classProperties=caption:Set+Value;iconSetStyle:VistaRound;baseColor:%23DDDDDD;disabled:False" onclick="javascript:UpdateValueList(integration.statusFieldId,integration.statusSubmit);" style="text-align:center;"/>

</div>

 

I am using an ID that has SYSADMIN, and I can manually update the values list and save and close the record.

 

 

Any idea what I am doing wrong?

 

Thanks,

Jeff

Jeff see how this updated code works.

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

function UpdateValueList(changeId, assignedValue) {
var valueArray = new Array(1);
valueArray[0] = assignedValue;

try {
$CM.setFieldValue(changeId, valueArray);
}
catch(e) {
console.log(e);
}
finally {
setTimeout(function(){ $('#master_btnSave').click(); }, 3000);
}
}
</script>

<div style="text-align:center;">
<img id="btnSaveAsDraft" src="BackgroundImageGenerator.axd?className=StyledButton&classProperties=caption:Save+as+Draft;iconSetStyle:VistaRound;baseColor:%23DDDDDD;disabled:False" onclick="javascript:UpdateValueList(integration.statusFieldId,integration.statusSubmit);" style="text-align:center;"/>
</div>

I have "junk" applications that have the same exact code and the values list set as dropdown and never generates the ReadOnly error.  I'm perplexed on what's causing the ReadOnly error.  So the try/catch/finally should take care of the issue.

 

I've added a setTimeout to handle the Unsaved Changes dialog box from appearing.  It seems applications that have fewer fields "save" faster and resets the dirty flag before the record exits.  You can shorten the timeout value to were it's acceptable.

 Advisory Consultant

Hi David.

 

This works! Thank you!

 

Jeff