Using a basic Template - Qlabs
Hello. I'm trying to get familiar with using the built in template function for a fairly basic script tied to Qlabs. The macro version I created works without an issue. However after I turn into a script and then template, it no longer works. All I'm looking to do is create a template so that allows me to enter the number vaule for the cue # to be triggered.
const cueNumber = event.props.cueNumber;
sf.ui.app('com.figure53.QLab.4').menuClick({
menuPath: ["Tools","Jump to cue..."],
});
sf.ui.app("com.figure53.QLab.4").windows.whoseTitle.is("Jump to Cue").first.elementWaitFor();
sf.ui.app("com.figure53.QLab.4").windows.whoseTitle.is("Jump to Cue").first.textFields.first.elementSetTextAreaValue({
value: "cueNumber",
});
sf.ui.app("com.figure53.QLab.4").windows.whoseTitle.is("Jump to Cue").first.buttons.whoseTitle.is("Jump to Cue").first.elementClick();
sf.ui.app("com.figure53.QLab.4").windows.whoseTitle.is("Jump to Cue").first.elementWaitFor({
waitType: "Disappear",
});
//Calling command "Qlabs - Go" from package "Encore"
sf.soundflow.runCommand({
commandId: 'package:ckv814sss0000yl106w3fz3qb',
props: {}
});
Once I run the command as this template. It types "cueNumber" in the text field instead of the desired cue number that I set in the template version. I apologize, my knowledge of javaScript is quite limited. Any help would be much appreciated!
- Kitch Membery @Kitch2021-10-26 20:28:22.346Z
Hi @Brian_Gluf
I'm unable to check it but...
Change
const cueNumber = event.props.cueNumber;
to
const {cueNumber} = event.props;
This will deconstructs the properties from the template. so you can then use
cueNumber
the same way as you use a variable. :-)Let me know if that makes sense.
- In reply toBrian_Gluf⬆:Kitch Membery @Kitch2021-10-26 20:34:15.621Z
You could also refactor the code to make it more readable like this.
const {cueNumber} = event.props; const qLab = sf.ui.app("com.figure53.QLab.4"); const jumpToCueWin = qLab.windows.whoseTitle.is("Jump to Cue").first; qLab.menuClick({ menuPath: ["Tools","Jump to cue..."], }); jumpToCueWin.elementWaitFor(); jumpToCueWin.textFields.first.elementSetTextAreaValue({ value: "cueNumber", }); jumpToCueWin.buttons.whoseTitle.is("Jump to Cue").first.elementClick(); jumpToCueWin.elementWaitFor({ waitType: "Disappear", }); //Calling command "Qlabs - Go" from package "Encore" sf.soundflow.runCommand({ commandId: 'package:ckv814sss0000yl106w3fz3qb', props: {} });
Rock on!
- BIn reply toBrian_Gluf⬆:Brian Gluf @Brian_Gluf
Thanks for your quick reply!
So both versions of what you suggested there get the the same error with a slight difference.
Error : Qlabs - Go: Line 1 (Cue 1 Go Copy line 21) Error: Qlabs - Go: Line 1 (Cue 1 Go Copy line 23)
I tried removing the "Go" part of the script enitrely, and it went back to using "cueNumber" as the text.
I set the template property type to String. That would be the right thing to use here correct?