Jump to content
Claris Engage 2025 - March 25-26 Austin Texas ×

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

Recommended Posts

  • Newbies
Posted

Is it possible to change a feilds colour within a script

ie

if feild "x" = "in progress" then i want feild "b" to change it's back ground colour to green

thanks,

Bill

Posted

Learner,

Scripts won't do what you're needing here. But the most recent thread in "Sights and Sounds" addresses how to achieve the effect of "conditional formatting", which seems to be what you need. There are quite a few ideas there. Best of luck -- feel free to follow up with questions if you have trouble implementing suggestions...

-ESpringer

Posted

This can be done equally well either by script or by calculation.

In either case, the technique most commonly used is to make the field itself transparent (ie apply transparent line and fill characteristics) and place it over the top of a container field. A third container field (a global field - not appearing on the layout) then holds one or more swatches of background color.

If you prefer a calculation method, the formula for the field which is placed behind your transparent data field would be along the lines of Case(YourConditionHere, gSwatch) - which will source the swatch from the gSwatch global field when the calc conditions are met.

If you want to achieve the same thing via script, then the back-most field should be an ordinary container field (as opposed to a calc field with a result type of container). The the script(s) with which you wish to change the apparent background color of the field should simply add the swatch to the container on the current record - eg with: Set Field ["StackedContainer", "gSwatch"] - or remove it with something along the lines of Set Field ["StackedContainer", ""].

If you want to create a script which toggles the background color on and off, you could use a script with a single step along the lines of:

Set Field ["StackedContainer", "Case(IsEmpty(StackedContainer), gSwatch)"]

So, for instance, with a toggling script such as this in place, you'd be able to attach the script to the field itself so that users would be able to click on the field to change its color - enabling users to go through a layout highlighting fields at will. wink.gif

Posted

Hi everyone!

Ray said...This can be done equally well either by script or by calculation.

In Bill's case, this may not be correct. It depends upon his needs but he said, "... then I want Field B to change its background colour." That implies a dynamic display at the data-entry level, ie, I type "In progress" into Field A and as soon as I leave Field A Field B will highlight. If Bill is simply looping through records, your script would work fine but if he wants dynamic, a scripted solution wouldn

  • Newbies
Posted

tHANKS THAT WORKED GREAT!

But one thing what happens if the feild changes to "not started" which is a nother colour. The container will not change unless it is clear, how do I clear it before another colour is placed in it?

Posted

I'm not quite sure I follow you.

Does your calculation look something like this:

Case(

Somefield="started", graphics::container1,

Somefield="not started", graphics::container2,

Somefield="cancelled", graphics::container3,

"")

You don't actually place the color in the field. The calculation does that depending on the value of the field it's based on ("Somefield" in my example). For however many different conditions you want to differentiate by color, you'll need that many container fields in your graphics file (or that many repetitions in your repeating field in your graphics file, if you chose to go that route), with each container field having a different colored rectange as its contents.

Does that help?

  • Newbies
Posted

okay that is the way that the script/condition is set up,

but if I select say "not started" it change the target container to blue, and THENin the same record if I change it to "in progress" then I want the Target feild/container to change to green, but it will not allow thew colour to change since there is the blue colour in the container from before, how do I clear the container within the Case statment before it puts in the new colour?

Posted

It sounds as though you gave entered your formula in as an auto-enter by calculation option.

Auto-enter calculations do not automatically clear the field and update when the values that they depend upon change. However calculation fields do.

If your field is a container field with an auto-entry specified for it, I suggest that you change the type of the field to 'calculation', then place your formula into the calculation dialog (making sure that the calcualtion result type is specified as 'container' on the drop down menu at the lower left of the calculation window). Then the color will automatically change whenever any of the fields your formula references are changed. wink.gif

Posted

learner said:

okay that is the way that the script/condition is set up,

but if I select say "not started" it change the target container to blue, and THENin the same record if I change it to "in progress" then I want the Target feild/container to change to green, but it will not allow thew colour to change since there is the blue colour in the container from before, how do I clear the container within the Case statment before it puts in the new colour?

Right...the blue container field will always contain a blue graphic. You need to have as many different container fields for as many conditions as you want to differentiate. You use the calculation to determine which container field to use based on the condition your testing for.

Have a look at the attached file.

John_Sample3.zip

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