Important Update: Community URLs redirect issues are partially resolved. 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

And I found that your case was in the radar once, though no definite resolution:

https://community.rsa.com/thread/198735

I checked and the ID values are correct. (And the Values List does get set to the desired value by the Custom Object, with the error being issued after the Values List is set).

Thanks. I see the same.

Okay, what is we try to cheat a little bit, as you said, that values are changed in the VL.

 

Try this:

<div style="margin: auto; width: 40%">
<div class="toolbar-app-buttons-left">
<a title="Save And Close" class="tb-btn-link-left" onclick="UpdateValueList(integration.statusField,integration.statusApprove);"; id="customSaveandClose" href="javascript:void(0);" data-check-dirty="true"> <div class="tb-btn" style="background-color:green; color:white">Save And Close</div>
</a>
</div>
</div>

<script type="text/javascript">
var integration = {
statusField:"22732",
statusApprove:"74218"
};

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

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

Thanks Ilya.

 

I tried the code that you provided with the try, catch, and finally statements. The code saves the record but it does not set the value in the Values List. I modified the code I have been using and I added the try, catch, and finally statements. Here is the current version.

 

<div style="margin: auto; width: 40%">

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

      <a title="Save And Close" class="tb-btn-link-left" id="customSaveandClose" href="javascript:void(0);" data-check-dirty="true"> <div class="tb-btn" style="background-color:green; color:white">Save And Close</div>

      </a>

   </div>

</div>

 

<script type="text/javascript">

var integration = {

   statusField:"21798",

   statusApprove:"74022"

};

 

function UpdateValueList(changeId, assignedValue) {

   var valueArray = new Array(1);

   valueArray[0] = assignedValue;  

   try {

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

         }

      catch(e) {

         console.log(e);

            }

      finally {

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

         }

}

 

$("#customSaveandClose").click(function(){

   UpdateValueList(integration.statusField,integration.statusApprove);

});

 

</script>

 

This version updates the Values List and it executes the save, but then after the record is saved I get the following warning message:

 

pastedImage_1.png

 

If I click on OK I am brought back to the list of records, and if I open the record I can see that the record was saved with the updated Values List.

 

Any idea why this warning message is being issued? Here is the error message from the DevTools console. 

 

pastedImage_2.png

 

Thanks,

Jeff

Jeff,

 

Try to remove this from the button:

data-check-dirty="true"‍‍

 

Though, I noticed that the change you did:

var integration = {
statusField:"21798",
statusApprove:"74022"
};‍‍‍‍‍‍‍‍

 

Meaning that the IDs were incorrect in your 1st example. So, it might be that your code was fine initially, but like I mentioned, IDs were the culpits  And your code or mine would work okay without Try-Catch-Finally with new IDs

Hi Ilya,

 

My apologies, the IDs were correct in the 1st example, but later I switched to a different Archer environment and I switched the IDs, but in the later code example I provided I forgot to mention that I had switched environments and IDs, so while I wish the IDs were the cause of the problem, they unfortunately are not. (I realize now that in the code example you provided I needed to update the IDs since I had switched to a new environment, but I forgot to do so, which is why the first time I tried your code it did not set the Values List). 

 

I took the code you provided and I switched the IDs to the new IDs. I then removed the data-check-dirty="true". The Values List is updated, the record is saved, but I still get the following warning and error messages from the console.

 

pastedImage_1.png

Here is the code I used:

 

<div style="margin: auto; width: 40%">

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

      <a title="Save And Close" class="tb-btn-link-left" onclick="UpdateValueList(integration.statusField,integration.statusApprove);"; id="customSaveandClose" href="javascript:void(0);" >

   <div class="tb-btn" style="background-color:green; color:white">Save And Close</div>

   </a>

</div>

</div>

 

<script type="text/javascript">

 

var integration = {

statusField:"21798",

statusApprove:"74022"

};

 

function UpdateValueList(changeId, assignedValue) {

 

var valueArray = new Array(1);

valueArray[0] = assignedValue;

try { $CM.setFieldValue(changeId, valueArray, ''); }

catch(e) { console.log(e); }

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

 

</script>

 

Just to be sure that the original problem isn't caused by incorrect IDs, I went back to the code without the try and catch logic and I still get the original error (the Values List is set but the record is not saved).

 

pastedImage_2.png

 

Here is the error:

 

pastedImage_3.png

 

I very much appreciate your help with this.

 

Thanks,

Jeff

This is probably the best we can do here. Probably this dirty check is happening due tot he the error in the setField() code, which we went around about.

 

Not sure we can fix it much without finding the root cause for the console error.

 

I would say, you can try to create ticket to support with your console error and the code.

And you may try to write custom code for removing the message, but there is no code available for that, I believe, and it would be a bit dangerous change as may backfire at later stages.

Thanks Ilya, I very much appreciate all the help you provided.

 

Does anyone from the RSA team have any guidance on how to resolve this problem?

 

Thanks,

Jeff

Jeff, your best bet here is either David Petty or official support channel