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

cancel
Showing results for 
Search instead for 
Did you mean: 

Custom Objects And You

DavidPetty
Archer Employee
Archer Employee

Welcome to my little space in the corner on Link dedicated to custom objects in Archer, RSA Archer Custom Objects" data-type="space

 

With this little community I plan on writing documents on various aspects to custom objects along with sample code and how they work within Archer to add a little bit of flair to your applications.

 

I'll start this off with a little background on what custom objects are.

 

What are Custom Objects

Custom objects is a layout object that allows you add HTML and JavaScript to an application.  With custom objects you can use them to manipulate an application to perform actions that cannot be done with calculate fields or Rules/Actions (DDEs).  Custom object can implemented based on the state of the record; meaning that it could only run if the record is in View mode, Edit mode or both View and Edit mode and it executes with the same permissions as the user has that's viewing/editing the record.

 

With custom objects you could perform the following:

  • Placing a button that could save the record, aside from the Save or Save and Close buttons located in the toolbar or set a values list, text, record permissions, date, numeric field.
  • Hide the various buttons in the toolbar by default or based on conditions in the record.
  • Populate fields with data by default or based on conditions in the record.
  • Hide the Add New/Lookup links for cross-references and sub-form fields.
  • For more advanced custom objects you can:
    • Use the REST or Web Services APIs to create or update records, initiate data feeds.
    • Call external APIs to pull data in.  Just be careful in that custom objects are stored in the browser as clear text and if you provide any credentials in the custom object the user could if savvy enough can find it. 

 

There are some concerns with custom objects to be aware of especially when it comes reading or updating fields in an application or questionnaire.  Archer uses the "field id" when it comes referencing fields in an application or questionnaire and these id's are specific to the environment.  So when you move an application or questionnaire to another environment the field id's will most likely be different and you would have to update those field id's each time you install a package.

 

if_warning_48_10375.png
  • Custom objects are limited just to the application/questionnaire meaning that they cannot be displayed in reports or notifications.
  • All field interactions (reading/update) must be on the layout but can be hidden with Apply Conditional Layout action.  With private fields the custom objects has the same access as the user.
  • Fields that are in a tab set that's not set as default are not accessible by custom objects.

 Advisory Consultant

78 REPLIES 78

RSAlover
Contributor

Thanks @DavidPetty , I'll test this out and report back!

RSAlover
Contributor

@DavidPetty the resource that you shared works perfectly on Version 6.7 P3.

Thank you!

DeanAllen
Contributor III

@DavidPetty  Was wondering if there is code that would allow us to automatically close the record as the last step in a custom object. We currently have custom code to grab the user that is clicking the AWF and would like the AWF button to also just close the record after the AWF has completed. saving steps for the user to remember. Thanks in advance.

Anonymous
Not applicable

You can emulate the X cross icon click I believe via Custom Object:

javascript:CloseRecord('recordClose')

I am probably not stating it correctly, or it is just that I don't know enough about javascript other than to be dangerous. We are in the middle of a AWF, and we have hijacked the AWF button to populate the current users name in a RecPermField. Currently, after the AWF button is clicked, it adds the name and a date(handled in AWF) and switches layout, and it remains in edit mode. We would like for it to close after it adds the name and triggers/finishes the AWF processing... We are ok if it is still processing when it closes, Just like if you were to click the exit in the pop up message. I am not sure where to put the code, as all of the places I have tried, it  it just closes the record as soon as it opens it on that layout.

<script type_="text/javascript">
 
       var usersName = parent.parent.ArcherApp.globals.displayName;
       var usersId = parent.parent.ArcherApp.globals.userId;
       
       var TransitionClickApprove = $('.tb-btn-link-left:contains("Submit Information Security Validation/Override")').prop("onclick");
              
       Sys.Application.add_load(function() {
       
              //Resets transition tab to validate rules
              $('.tb-btn-link-left:contains("Submit Information Security Validation/Override")').removeAttr('onclick').unbind('click');
              $('.tb-btn-link-left:contains("Submit Information Security Validation/Override")').prop("onclick", null);
              $('.tb-btn-link-left:contains("Submit Information Security Validation/Override")').click(function() { Approve(); });
       });

       function Approve() {
              var fldId = 'xxxxx';
              AssignUser(fldId);
              TransitionClickApprove();
       }
       
       function AssignUser(fldId) {
              var RPFieldRoot = ArcherTech.UI.ClientContentManager.GetInstance().getFieldById(fldId), UsrArray = [];
              var RPFieldRootId = RPFieldRoot.clientId;
              UsrArray.push({ name: usersName, value: usersId + ':1' });
              var serialized = Sys.Serialization.JavaScriptSerializer.serialize(UsrArray);
              $('div[id*="'+ RPFieldRootId +'_"] div:first-child').text(usersName);
              $('input[id*="'+ RPFieldRootId +'_"]').val(serialized);
              $('#SelectedUsers'+fldId).val(usersId);
       }
       
       </script>

 

Anonymous
Not applicable

You need to use HTML sessions most probably, because right after AWF starts processing record is already saved. Thus upon next load, you need to check session variable, clean variable and close record.

https://www.w3schools.com/html/html5_webstorage.asp 

OK, I think I understand...

  • As part of AWF button click execution, set a variable to a value.
  • Create a custom object (HTML) that is on layout of the destination Layout after completion of AWF. 
    • If that variable == "Value"
      • clear variable
      • close record
    • Else
      • do nothing

@DeanAllen, the issue is that page is reloaded and whatever the state of the variable is will be reverted back to 'default' value.

I've been using Window.sessionStorage - Web APIs | MDN (mozilla.org) to store and retrieve variables that are needed on page reload to do work after a post-save.

 Advisory Consultant

I was able to get done what I needed, but it is not necessarily clean/efficient. As I am a newbie to JS, this is what I did... Note: As part of the AWF button press I set the value of the Auto Close Flag to Yes. After it does the normal processing of the AWF there is a delay of a few seconds and the CustomObject runs/triggers, checks if the flag is Yes. If it is, it sets the value to No, and then saves and closes, otherwise it remains open.  Now if I could just figure a way to easily set another flag is an associated record to yes so I could trigger another save.

<script type_="text/javascript">     

Sys.Application.add_load(function() {

  // Auto-Closes record if Auto Close Flag  = Yes
if($CM.getFieldValue(39989) == "152:0") {

  // Create Array - assign value to be input - insert value into field
var valueArray = new Array(1);
valueArray[0] = "155";
$CM.setFieldValue(39989, valueArray, '');

  // Save and Close
$("#master_btnSave1").click();          

};     

});