Important Update: Archer Community Scheduled Maintenance on November 23–24 - New Community Launching Soon! 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,  Archer Custom Objects Forum - Archer Community

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

JaganChandrava1
Contributor III

<script type="text/javascript">
var valuesListFieldId = 18829; // This is the field id of the values list
var valuesListValueAId = 54847; // This is the id of the value to check against
var valuesListValueBId = 39148; // This is the id of the value to check against
var valuesListValue;

Sys.Application.add_load(function() {
var recordMode = ArcherTech.UI.GenericContent.GetInstance().get_mode(); // 1 = Edit, 2= View

if(recordMode == 1){
valuesListValue = getValue(valuesListFieldId);
}else if(recordMode == 2) {
valuesListValue = $('div[id*="f' + valuesListFieldId + 'c"] div:last').attr('data-valueslistvalueid');
}

if (valuesListValue.indexOf(valuesListValueAId) != -1 || valuesListValue.indexOf(valuesListValueBId) != -1 ) {
$('#master_btnCopy').hide();
$('.rmLink:Contains("Copy")').parent().parent().hide();
$('.rmText:Contains("Copy")').closest('li').remove();
}
});

function getValue(fldId) {
var RPFieldRoot = ArcherTech.UI.ClientContentManager.GetInstance().getFieldById(fldId);
var RPFieldRootId = RPFieldRoot.clientId;

return $('input[id*="'+ RPFieldRootId +'"]').val();
}
</script>

DavidPetty
Archer Employee
Archer Employee

Thanks.  Are there any errors being thrown in the browser's console?

 Advisory Consultant

JaganChandrava1
Contributor III

David,

The record keeps on loading while opening. pastedImage_1.png

 

If we remove the custom code. It is working normal.

DavidPetty
Archer Employee
Archer Employee

Jagan, open the browsers developer tools and select the console before opening a record, then open a record.  Any errors being thrown?

 Advisory Consultant

JaganChandrava1
Contributor III

David,

 

Please find the Error:

pastedImage_1.png

DavidPetty
Archer Employee
Archer Employee

Thanks, if you click on Record.aspx (1399,11) it should take you to the line that threw the error.

 Advisory Consultant

JaganChandrava1
Contributor III

Error:

 

pastedImage_1.png

DavidPetty
Archer Employee
Archer Employee

Looks like the variable valuesListValue might not have a value and the indexOf is failing.  Make sure the field Id you're passing to the getValue() function is valid and that the field is on the layout and not in a tab that not selected.

 Advisory Consultant

JaganChandrava1
Contributor III

That is a calculated field. Won't that works? 

JaganChandrava1
Contributor III

David Petty‌, It seems the script is not working for calculated field. This is similar to DDE changes. Is there any way to update based on the calculated field?

 

Thanks...