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

cancel
Showing results for 
Search instead for 
Did you mean: 

Appointment - Custom Object to taylor how Archer accounts for utilization

JeffConti
Contributor III

We track resource usage, allocation, and base availability by day. Archer was designed to do this by hour, and disabled the appointment application from being changed. The script I brutally composed (very new to JavaScript) bypasses the need for a scheduler to input a value into the hours box. The box and its field name are hidden upon opening the form. When an appointment is saved, the mouseover of the save button invokes the function to unhide the duration input box while setting that value to 0. This allows the record to be saved without receiving error that a required field was not populated.

 

Additional elements were added to this script but remarked out because I could not get the functions to work. 

 

Element IDs within the Appointment needing to be noted consist of the following:
Phase: master_DefaultContent_rts_s3030_f20450c
Appointment Start Date: master_DefaultContent_rts_s3030_f16683c
Appointment End Date: master_DefaultContent_rts_s3030_f16684c
Save Button: master_btnSave
Duration (Hours): loitem20386 ░░░░░░░░░░░░░░░ : master_DefaultContent_rts_s3030_f16685c
Name Field: loitem20390
Name Input Box: master_DefaultContent_rts_s3030_f16686c
DaysAutoCalc: master_DefaultContent_rts_s3030_f25076c (Created by me - calculates the working days then multiplies that by a Value List allocation of 25, 50, 75, or 100% through an Archer calc field)
HoursAutoCalc: master_DefaultContent_rts_s3030_f25074c (Created by me multiplies daysautocalc by 8)

Time Allocation Value List Combo Box: master_DefaultContent_rts_s3030_f25080c_ddl
Non-Audit Activity Combo Box: master_DefaultContent_rts_s3030_f20449c_ddl
Parent Combo Box Input: master_DefaultContent_rts_s3768_parentLevelComboBox_Input
Parent Lookup Result: master_DefaultContent_rts_s3768_parentLookup
Resource Combo Box Input: master_DefaultContent_rts_s3768_resourceLevelComboBox_Input
Resource Lookup Result: master_DefaultContent_rts_s3768_resourceLookup

 

The following is the current script used :

 

   <script>
    document.getElementById("loitem20386").style.display = "none"; //hide Duration (Hours)
    document.getElementById("master_DefaultContent_rts_s3030_f16685c").style.display = "none"; //Hide Input for Duration (Hours)
    document.getElementById("master_btnSave").onmouseover = function() {setDays()}; //invoke functions when saving

 

  function setDays() {
    var days = 0; //initializing variable to 0
    document.getElementById("master_DefaultContent_rts_s3030_f16685c").style.display = "block"; //reveal hours input
    document.getElementById("master_DefaultContent_rts_s3030_f16685c").value = days; //set hours to 0
    document.getElementById("master_DefaultContent_rts_s3030_f16685c").focus(); //focuses on hours field so record will save without error 
   }
   </script>

 

This was done after struggling and failing at what I really was trying to accomplish which was on saving the form, grab the start and end dates, calculate the number of working days (weekdays), multiply that by the allocation percentage, place the resulting value in a numeric field, multiply that by 8 and have that value placed in the Duration (Hours) field.

 

Also, and this is huge, I needed to get the phase value concatenate it with colon, and concatenate that with a space and concatenate that with the Parent field lookup value(indicating the audit name) and use that to populate the optional Name field.  I ended up just moving the Name field off of layout (because I couldn't get it to work), but need to put it back and populate it if I can get it done.  Oh, but if Non Audit Activity was chosen, then Name would be populated with that Value List selection.

 

My biggest problem.....  and don't laugh....  I could not for my life figure out how to extract the data from within a field on a form.  I even found a great JavaScript that would calculate the working days (week days) between two dates (to take the place of the calculated field).  

 

Alternatively, I figured...  If I could just get the form to save first...  and by save I mean element ID master_btnApply, then i could just use Archer's calculation engine and leverage the output to those assigned field where I have already calculated the days, hours, etc.  

 

pastedImage_19.png

20 REPLIES 20

Great!  Thanks for sharing!