Jump to content
Claris Engage 2025 - March 25-26 Austin Texas ×
The Claris Museum: The Vault of FileMaker Antiquities at Claris Engage 2025! ×

This topic is 7091 days old. Please don't post here. Open a new topic instead.

Recommended Posts

Posted

I have wrote a script as below which is for showing a message...

but it can't auto update when (Current DAte) Was change, is anyone can tell me what should I do?

If (StartDate < Get(CurrentDate) and EndDate > Get(CurrentDate) ; TextColor ("Processing" ; RGB ( 100 ; 154 ; 244) ))

&

If (StartDate > Get(CurrentDate) ; TextColor ( "Comming" ; RGB ( 255 ; 0 ; 0 ) ))

&

If (EndDate < Get(CurrentDate) ; TextColor ("Finished"; RGB ( 172 ; 172 ; 172 ) ))

Posted

I understand that tis is not script. I think that this is calculation for field. If such then you will be better use Case() function

Posted (edited)

You have a few things that need fixed. First, the & is unnecessary. You have not accounted for the current date, ie, each comparison is less than or greater than but none addresses current date. And a Case() would certainly work a bit better. Also, your existing calc produces both [color:red]Comming and [color:gray]Finished if the StartDate is greater than today and there is no end date listed. I suggest a small change should work better for you, something like:

Let( now = Get(CurrentDate) ;

Case(StartDate > now ; TextColor ( "Comming" ; RGB ( 255 ; 0 ; 0 ) ) ;

EndDate < now ; TextColor ("Finished"; RGB ( 172 ; 172 ; 172 ) ) ;

TextColor ("Processing" ; RGB ( 100 ; 154 ; 244) ))

)

And, since it's based upon Get(CurrentDate), this must be unstored (in Storage Options). Set this calculation to text result. Oh. And 'comming' is usually spelled coming, I think. But it may be spelled differently in different parts of the world. :wink2:

UPDATE: Oh. I can't help myself ... if someone wants it more efficient, they can replace the RGB() entirely. It will save a few evaluations. The calc would then become:

Let(

now = Get(CurrentDate) ;

Case(StartDate > now ; TextColor ( "Comming" ; 16711680 ) ;

EndDate < now ; TextColor ("Finished"; 11316396 ) ;

TextColor ("Processing" ; 6593268 ))

)

... okay, I feel better. You can copy then paste either calculation directly into your calc box. I would use the second calc unless someone proposes a better one ... then I'd use it instead! :laugh2:

LaRetta

Edited by Guest
Posted

Thank you, Thank you very much, and I have another question No. which is how can I get the Login in the in script?

Posted

Hi Ham,

I am baffled by why you would want to use script for this when the field can change all by itself daily?! Otherwise, you'll be having to loop a script through your records every single day to keep it updated!

Nonetheless ... just use the calculation in a Set Field [ ] script-step to set a TEXT FIELD. If you have a group of records, oh geez, you REALLY don't need to set them manually, you would need a loop, something like:

Go To Record/Request/Page [ First ]

Loop

Set Field [ yourTextField ; above calc ]

Go To Record/Request/Page [ Exit after Last ; Next ]

End Loop

Again, it's unnecessary. If you just let an unstored calculation handle it for you, and as your StartDate and EndDate are changed or entered in each record, the results will automatically change depending upon the current date. No need for script. :smile2:

UPDATE: Wait. Login? I just woke up. I thought it said 'get the LOGIC in the script.' If you have a question about Logins in a script, I suggest you start another post in the appropriate section, okay?

LaRetta

This topic is 7091 days old. Please don't post here. Open a new topic instead.

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use.