Executing script based on button

I have a button on a popup screen I am executing a script on. I have put the script in the Scripting folder.
I have created a function called parts_in_entry. I am also passing in a parameter from the popup screen (view) called CellId. I have tried numerous things and my script does not seem to work in the scripting folder. Also I have tried the print function to get something to work on the output console and outside of saving the project none of the ‘print’ commands work.

Here is the script I have in the scripting folder. The script is called EntryControl.

I had it working, at least the first part of the if statement, when I actually defined the cellid inside of the function and tied it to self.view.params.CellId but thought why not just pass it along as a parameter. I am using wrong formatting?

I also put the print command within the function and still nothing in the output console

You’ve got some mistakes in your thinking about how things work.
First, you’re passing a literal string '{self.view.params.cellId}' in to your project script. That’s not going to be replaced by anything, or do anything dynamic - it’s just going to be a string when it makes it into your script. Curly brace dynamic value lookups only happen in expressions - not in scripting. If you want to pass just the value of a parameter, then you should use it verbatim: EntryControl.parts_in_entry(self.view.params.cellId)
However, that will bring you to your next problem; on line 13 of your EntryControl script you’re calling self.getSibling - but what is self? Since you’ve jumped into a project script, you no longer have the explicit parameters you have in the runAction block. If you want to reference self or event in your project script, you must explicitly pass them along (or, in this case, better style - just pass the value you want to read as well).

1 Like

Thanks! Makes sense and was able to get it working.
Just like I can pass in self or event properties into the project script, can I also pass out or change self properties from the script?

Yes, you can - just that it (can be) confusing to reason about things if you pass variables around, especially since you can rename them with every layer of indirection.

Right. Good to know, thanks.