Jump to content

script for changing text colours


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

Recommended Posts

I have a date field (invoices::payment due) included in a portal on another layout called 'update'. I'm trying to devise a script that will apply a text style (such as a different RGB value) to all dates in 'invoices::payment due' that are less than the current date, in other words invoices that are overdue.

I have a 'current date' field in my 'update' layout, which is updated every time the file is opened, if it's needed, but I can't figure out how to phrase the changing of the text colour. If style changes can only be applied to text fields then I can apply it to the invoice title instead (invoices::job title)

Any pointers would be appreciated.

Link to comment
Share on other sites

Thanks Wim.

I've put a script together, but it has one small bug which I can't figure out. I've attached a screenshot here of the portal and the script itself, so you can see how it's working.

All the fields you can see in the portal are from the table 'jobsheet 3', except for the unlabelled field on the right. The field under the label 'deadline' is the field named 'finished art' in the script. The field 'update::date' in the script is a field in the current layout which always contains today's date (currently 29/09/2004 - european date format dd mm yyyy)

The sub-scripts in my main script insert the appropriate coloured text in the unlabelled field on the right. The problem I'm having is that the script returns an incorrect result ('pending' - should be 'late') in the first line of the portal. All the other results are correct. Also, if I remove the 'Pause/resume' step after 'end if', the script returns 'pending' in all the portal rows.

Any ideas?

portal.jpg

Link to comment
Share on other sites

I think it would be cleaner and more accurate to Go to Related Records [show; relationship] and loop on the found set instead of looping through the portal. Also, use Get(CurrentDate) instead of Update::Date and see if your results are correct.

Alternatively, don't use a script at all. Make your Pending/Today/Tomorrow/etc. field an unstored text calculation in the related table that uses the tests in a Case statement and returns the appropriate TextColor result.

Link to comment
Share on other sites

This topic is 7204 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.