Skip to main content
Jennell_McIntire
Employee
Employee

The ObjectID and InObject functions are system functions that can only be used in chart expressions. The ObjectID function has one optional parameter and is used to return the object ID of the object the expression is in or of the object type that is included in the parameter. A text & image object with ObjectID() in the expression returns the ID of the text & image object. ObjectID('text-image') also returns the ID of the text & image object. To determine the ID of the sheet the object is on, use the expression ObjectID('sheet'). This will return the ID of the sheet just as you see it in the URL of an app.

ObjectID and URL - Copy2.png

In the example below, there are 4 sheets and a button from the master items is on each sheet. An expression is used to color the background of the button based on the sheet it is on. In this expression, the ObjectID function is used to check the sheet ID before assigning the button color.

button expression.png

Here are the results:

blue.png          green.png

red.png          grey.png

The InObject function takes one parameter, which is the ID of an object, and is used to determine if the current object, (where the expression is written), is contained in another object. In the text & image expression below, the InObject function is used to see if the text & image object is in the sheet with ID '040e64b6-4a93-4962-a833-aed253db4ac1'. In this case, the expression returned true (-1) because the text & image object is in the identified sheet. If the expression was false, 0 would have been returned.

inobject.png

The InObject function can also be used to color buttons as done in the previous example. In this example, there are three sheets – a navigation sheet, a blue sheet, and a green sheet. On the navigation sheet there are two master buttons that will navigation the user to the respective sheet.

navigate.png

In the background color expression for the blue sheet, the InObject function is used to determine if the blue sheet button is in the blue sheet. If it is, then the button is colored blue, otherwise it is colored light gray. The parameter used in the InObject function is the sheet ID for the blue sheet.

blue expression.png

A similar expression is used for the background color expression of the green sheet button except in this expression, the parameter is the sheet ID for the green sheet.

green expression.png

When the blue sheet button is clicked, the user is directed to the blue sheet and the buttons looks like this:

blue sheet.png

When the green sheet button is clicked, the user is directed to the green sheet and the buttons looks like this:

green sheet.png

Below is another example of the InObject function with a few levels. There is a text & image object in a container object on a sheet. The first three expressions below use the ObjectID function to get the object IDs for the sheet, container, and text & image objects. The last three expressions use the InObject function to confirm that the text & image object is in the container, that the text & image object is in the sheet, and that the text & image object is not in the next sheet.

container3.png

I would love to hear how you use the ObjectID and InObject functions – share in the comments.

Thanks,

Jennell

 

 

 

 

1 Comment