Ask a Question

Code Expression

gdave
Regular Contributor

Code Expression

Hi

 

Kindly refere to the attached screenshot before you read the below query so that it will make more sense..

 

I need to enter today's date in my date cell (called effective end date) for which I used 'Keys' operation and for the 'Value' I used code expression as "aqConvert.DateTimetoFormatStr(aqDateTime.Today(), '%d/%m/%Y')". This however didn't work as expected but surprisingly only date part was executed and I could see the date format as 13/00/0003.

 

Can someone please advise where have I gone wrong ?

 

Also I'll appreciate if you can provide me the solution to enter yesterday's date instead of today. Thanks

8 REPLIES 8
shankar_r
Community Hero

It looks like issue when you use Keys() method.

 

Have you tried SetText() function? if not please try using this.

 

 


Thanks
Shankar R

LinkedIn | CG-VAK Software | Bitbucket | shankarr.75@gmail.com

“You must expect great things from you, before you can do them”

Extension Available

gdave
Regular Contributor

Just tried Settext function, my test doesn't fail but it does not populate date in the date field as well.


@shankar_rwrote:

It looks like issue when you use Keys() method.

 

Have you tried SetText() function? if not please try using this.

 

 


 

Then i would suggest to select by using calendar object which you will get by clicking down arrow.


Thanks
Shankar R

LinkedIn | CG-VAK Software | Bitbucket | shankarr.75@gmail.com

“You must expect great things from you, before you can do them”

Extension Available

gdave
Regular Contributor

Yes that is an option but that option doesn't allow me to enter yesterday's date and that's the reason I was wondering if using code expression can sort that issue.


@gdavewrote:

Just tried Settext function, my test doesn't fail but it does not populate date in the date field as well.


@shankar_rwrote:

It looks like issue when you use Keys() method.

 

Have you tried SetText() function? if not please try using this.

 

 


 


 

gdave
Regular Contributor

Yes that is an option but that option doesn't allow me to enter yesterday's date and that's the reason I was wondering if using code expression can sort that issue.


@shankar_rwrote:

Then i would suggest to select by using calendar object which you will get by clicking down arrow.


 

tristaanogre
Esteemed Contributor

The code expression, as it is, is correct.  So, that's not the issue.

 

Here's my guess... and I'm not 100% certain...  but it looks like your control may be applying some auto-formatting.  

 

If you were to manually type the value into that field, do you need to add the "/" characters or are they automatically added by the control?  What happens if you change the code expression to remove the slash characters?  

 

Although, this may only delay the problem because, if you get to a day of the month that is single digit, you may still need to have some way to go to the next field.  So... as suggested, rather than using keys, there may be some other method or function you might need to try.  Examine the properties of your control to see if there is something like a "wDate" field or something else that you can set the value of rather than using the "Keys" method.


Robert Martin
[Hall of Fame]
Please consider giving a Kudo if I write good stuff
----

Why automate?  I do automated testing because there's only so much a human being can do and remain healthy.  Sleep is a requirement.  So, while people sleep, automation that I create does what I've described above in order to make sure that nothing gets past the final defense of the testing group.
I love good food, good books, good friends, and good fun.

Mysterious Gremlin Master
Vegas Thrill Rider
Extensions available

To expand on this, I agree with @tristaanogre here in that the masking on your field probably cannot keep up with the speed of the keys method. I have seen this a lot in different applications. 


Thanks,
Carson

Click the Accept as Solution button if my answer has helped
gdave
Regular Contributor


@tristaanogrewrote:

The code expression, as it is, is correct.  So, that's not the issue.

 

Here's my guess... and I'm not 100% certain...  but it looks like your control may be applying some auto-formatting.  

 

If you were to manually type the value into that field, do you need to add the "/" characters or are they automatically added by the control?  What happens if you change the code expression to remove the slash characters?  

 

Although, this may only delay the problem because, if you get to a day of the month that is single digit, you may still need to have some way to go to the next field.  So... as suggested, rather than using keys, there may be some other method or function you might need to try.  Examine the properties of your control to see if there is something like a "wDate" field or something else that you can set the value of rather than using the "Keys" method.



There's no difference  in outcome upon removing "/" character. However I've got a workaround now and I am no loger pursuing code expression route. Thanks for your input though.

 

 

Regards

G

cancel
Showing results for 
Search instead for 
Did you mean: