cancel
Showing results for 
Search instead for 
Did you mean: 

Date Validation Custom Object

AkshayDaniel
Contributor III

Hi All,

 

I am in the process of creating object for validating date in one of the Archer application however I am stuck with having a proper event listener for the date field, since most of the Javascript event listeners do not work inside custom object, I tried with Jquery selector aswell but that also does not seem to be responding to the event trigger, I have the following observations 

 

1. wrapping the event trigger inside Sys.Application.add_load() or $(document).ready() does not affect the behavior of event trigger the Javascript code only works when the form is loaded and while conditional layout makes the field visible, it overlooks the event trigger always

 

<script type="text/javascript">

Sys.Application.add_load(function(){

$("input[name='master$DefaultContent$rts$s7604$f21390cdp']").change(console.log("value change"));
});

</script>

2. There are certain examples in community which select the wrapper div tag Id instead of the date field itself name selection but that also did not fetch any positive result.

 

My end goal is to have the event triggered every time the user has filled the date field i.e. onfocusout() or onblur() please share your thoughts and corrections I need to do in my script

1 ACCEPTED SOLUTION

Accepted Solutions

For whatever reason the developers never gave the input element an id

 

I just tested this in my environment and it works properly; 'Date field changed' shows up in the browser console.

<script type="text/javascript">
     var fldId = 19670;

     Sys.Application.add_load(function() {
          $('div[id*="f' + fldId + 'cdp"]').change(function(){
               console.log("Date field changed");
          });
     });
</script>
‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍

 

The reason I'm checking if the div changed is that the change event won't work on the input box because Archer is setting the value.  The even only triggers if its inputted by a user.

 

Is the date field being set other than the date picker like a rule/action?

 

UPDATED:  Change the jQuery selector from $ to * do to inconsistencies in the custom object working properly.

 Advisory Consultant - Archer, an RSA Business

View solution in original post

18 REPLIES 18

Ilya_Khen
Champion III

Maybe this will give some hint. https://community.rsa.com/thread/85285 

DavidPetty
Archer Employee
Archer Employee

Akshay depending on the version of Archer you're on, I've seen some strangeness around the session number (S7604) changing when saving the application in the application builder.  So I'm going to look for the element id that contains the field id instead.  Makes better code management when moving from one environment to another.  Also I'm going to check for change in the div instead of the input element.

 

See if the update below is any better .

 

<script type="text/javascript">
     var dateFieldId = 21390;
     Sys.Application.add_load(function(){
          $('div[id*="f' + dateFieldId + 'cdp"]').change(console.log("value change"));
     });
</script>
‍‍‍‍‍‍

 Advisory Consultant - Archer, an RSA Business

Thanks David and Ilya for your response we are currently on Archer6.4 HF1.

 

@David ,

 

I tried with the code you mentioned however no luck it does work only when the page loads, after that it does not work if there are any changes to the date

 

Also from Jquery selector you wrote it seems that we should have an Id for date field but we do not have that, upon inspecting the element I get the following HTML code 

 

<div id="master_DefaultContent_rts_s7604_f21390cdp" class="archer_ui_datetime"><input name="master$DefaultContent$rts$s7604$f21390cdp" type="text" aria-labelledby="loitem46734" style="width: 200px;"><a aria-label="Date Picker" class="date" tabindex="0"></a><a aria-label="Time Picker" class="time" tabindex="0" style="display: none;"></a></div>

 

Kindly advise

Your ID is 21390 based on the HTML code. 

yes Ilya but I am not sure why this selector does not work inside IE console, could this be the reason for event not getting triggered 

Have you tried in other browsers?

to provide more context on how i am debugging the issue i would usually open up developer console in IE and try the Jquery selector first, if i am able to select the element then i try rest of the code.

yes chrome and IE both provide the same result

For whatever reason the developers never gave the input element an id

 

I just tested this in my environment and it works properly; 'Date field changed' shows up in the browser console.

<script type="text/javascript">
     var fldId = 19670;

     Sys.Application.add_load(function() {
          $('div[id*="f' + fldId + 'cdp"]').change(function(){
               console.log("Date field changed");
          });
     });
</script>
‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍

 

The reason I'm checking if the div changed is that the change event won't work on the input box because Archer is setting the value.  The even only triggers if its inputted by a user.

 

Is the date field being set other than the date picker like a rule/action?

 

UPDATED:  Change the jQuery selector from $ to * do to inconsistencies in the custom object working properly.

 Advisory Consultant - Archer, an RSA Business