Filemaker PSoS go to layout - filemaker

I am trying to use Perform Script on Server function to improve speed of my database.
I make a very simple function but the "go to layout" function doesn't works. I used a field to make sure that the function is running on server.
"Main script":
perform script on server [Wait for completion; "PSOS script"]
"PSOS script":
set Field [Table::field ; Table::field & " PSOS script is running on server "]
go to layout["simpleLayout"]
"OnFirstWindowOpen"
If[LeftWords (Get (ApplicationVersion) ; 1) = "Server")]
set Field [Table::field ; Table::field & " OnFirstWindowOpen is running on server "]
Exit Script[];
End If
When I run the "Main script" the result of Table::field is:" OnFirstWindowOpen is running on server PSOS script is running on server", but I stay in the same layout.
My database is host in FMPhost.com cloud filemaker server 14.
Thanks.

What I think is confusing you is that when you perform a script on server, the server actually opens a separate instance of the database on the server.
It runs the startup script first, then your specified script.
You will not see any layout navigation in your local FileMaker as the layout change happens in the instance the server has opened.
You need to do all navigation scripting directly, for example by moving your go to layout step to your main script after the perform on server step.
More info on the function here.

Go to layout is PSOS compatible
Unless your PSOS script sets the global field, this field has to be on the first layout open.
Try to add another go to layout script step before you set the field through PSOS.
Another option - set the error capture on and parse the error back to your local script or check server log to track the issue.
go to layout["simpleLayout"]
Are you trying to pass a layout name into calculation? You need to either select it from the list or use layout number

Try adding "Go To Layout" Script step at the very beginning of the script, before "Set Field" navigating to the layout, where you need to set that field.
"PSOS script":
Go To Layout ["layoutName"]
set Field [Table::field ; Table::field & " PSOS script is running on server "]
go to layout["simpleLayout"]

Related

Execute SSIS (package) in SSMS using T-SQL and return a value

Using VS (2019) I created an Integration Services Project to code an SSIS package. The goal was to call a Web API from an SSIS package using input variables like username/password/url and so on. I successfully achieved this using Script Task and Dts.Variables and F5/Run to see successful results. What I want to achieve now is to return (like an out parameter) an Id returned to me by the Web API. I want to have this Id returned in the SSMS Results window when I execute the SSIS script in SSMS.
Here is what I have done:
VS > Open dtsx file in Designer and in the "Control Flow" tab, right clicked to add variable:
Right clicked the Script Task I had created and added the variable created above in the ReadWriteVariables section:
Using "Edit Script" to code the Web API call and return a value and set it as follows:
//MessageBox.Show(id);
Dts.Variables["User::Id"].Value = Convert.ToInt32(id);
The MessageBox was just to test if the id is returned by the Web API and I get an alert of the "id" when I Run/F5 the SSIS project in Visual Studio. The second line is where I have set the Variable.
I execute the SSIS in using T-SQL in SSMS from an example here:
Declare #execution_id bigint
EXEC [SSISDB].[catalog].[create_execution] #package_name=N'ssisWAP.dtsx', #execution_id=#execution_id OUTPUT, #folder_name=N'SSIFolder', #project_name=N'SampleProject', #use32bitruntime=False, #reference_id=Null
Select #execution_id
DECLARE #var0 sql_variant = N'username'
EXEC [SSISDB].[catalog].[set_execution_parameter_value] #execution_id, #object_type=20, #parameter_name=N'Username', #parameter_value=#var0
DECLARE #var1 sql_variant = N'password'
EXEC [SSISDB].[catalog].[set_execution_parameter_value] #execution_id, #object_type=20, #parameter_name=N'Password', #parameter_value=#var1
EXEC [SSISDB].[catalog].[start_execution] #execution_id
The above executes properly, calling the API and an out #execution_id is shown in Result window. But no sign of the variables User::Id I created earlier. Is it possible to show that value in the Result window? If not, is there a way to see that the data in that variable in SSMS after SSIS execution (even from designer)?
I already had a look at this post: Returning Output Paramters or Variables From SSIS Script Task / Script Component
where the solution is to use "Execute SQL Task" and "pass" the variable into a procedure. This I guess is one way to do it but I want to just get the Id in the return when I execute the script as shown above.
Any help will be appreciated. Thanks

How to trigger RegenerateUserEnvironment forcibly

I'm currently having trouble applying logon script(powershell) on windows servers.
The logon script has the line to set user environment variables but the variables don't look like being applying immediately from the result of set command on command prompts.
I've been looking at the behavior through process monitor while logging on to the new session.
And finally I have found the newly created variables need to be associated with RegenerateUserEnvironment function on shell32.dll.
I'm able to look at the correct result of set command after RegenerateUserEnvironment is called.
So I was wondering whether we had a way to trigger RegenerateUserEnvironment function and it needs to be executed on powershell.
Can you shed some light on this?
Best Regards,
Haewon

Creating a checkbox with powershell and running actions based on selections?

I know how to "draw" a window using powershell to display check boxes. However, that is about all I have been able to figure out. I want to display a list of virtual machines stored on an ESXI server (I can just set this statically as the list shouldn't change). What I need to figure out is how to make a check box cause vmrun to execute a power on for the machine. So basically I have four check boxes with say "VM01" , "VM02" , "VM03", "VM04". How can I have the checked boxes returned and say if VM01 & VM03 are checked turn on the machines. I have the power on scripts stored as variables
You need to add an event handler to the Click event. Add your code to the handler scriptblock.
$checkboxAll.add_Click($handler_checkboxAll_Click)
$handler_checkboxAll_Click=
{
if ($checkboxAll.Checked)
{
#do stuff if the box is checked
}
}

NirCMD run multiple commands from a context menu

I would like to run a few NirCmds when running an application such that it will change the primary display to the extended monitor, run the app and then switch back when finished. Ideally I would like to create this as a context menu option. Since this is using multiple commands I thought of using the script functionality from nircmd such as:
script "$folder.desktop/testscript.ncl"
with the script containing the lines I needed:
setprimarydisplay(2)
exec max "???.exe"
waitprocess ???.exe setprimarydisplay(1)
However I am not sure how to pass the process name from the context menu into the script or if this is even possible. Does anyone know how to do this or am I approaching this the wrong way?
I have the process location from the context menu as %1, so the issue is really just passing this into the script. Something like:
script "$folder.desktop/testscript.ncl" -%1

Import AppleScript methods in another AppleScript?

Is there a way to use defined AppleScript methods in other AppleScripts which reference the original AppleScript with something similar to import (f.e. in PHP)?
I wrote a methode to set Skype status and mood-text:
on setSkypeStatus(status, mood_text)
tell application "System Events"
set skypeRunning to count (every process whose name is "Skype")
if skypeRunning > 0 then --only set status if skype is running
tell application "Skype"
set myStatus to "SET USERSTATUS " & status
set myMood to "SET PROFILE MOOD_TEXT " & mood_text
send command myStatus script name "AppleScript"
send command myMood script name "AppleScript"
return skypeRunning
end tell
else
return skypeRunning
end if
end tell
end setSkypeStatus
now I'm searching for something like import skype_methods.scpt. Is there such a functionality. I can't something related with Google.
One way to import another script as a library is to define a property which is initialized by loading the library as a script object. You can then use the tell command to invoke the library functions.
property pSkypeLibrary : load script POSIX file "/Users/sakra/Desktop/skype_methods.scpt"
tell pSkypeLibrary
setSkypeStatus("status", "mood")
end tell
Script Foo.scpt
set theBar to "path:to:Bar.scpt" as alias
run script (theBar)
Script Bar.scpt
display dialog "Bar"
Result: A window that displays "Bar"
There is a more elegant way of doing this. You can save your skype_methods.scpt file inside a Script Libraries folder on your computer.
Depending on how you want to define the availability of this library, you use a different folder.
Place the skype_methods.scpt file inside the /Library/Script Libraries folder to make it available for all users on the computer.
Place it in the ~/Library/Script Libraries folder to make it available for a specific user only.
You can then use all the handlers in that library as follows:
property Skype : script "skype_methods"
Skype's setSkypeStatus("status","mood")
This prevents the need of numerous tell blocks when using handlers from different libraries.
You can follow this repo https://github.com/abbeycode/AppleScripts which organises its scripts into libraries
Here is an example https://github.com/abbeycode/AppleScripts/blob/master/Scripts/Download%20Chase%20Activity.applescript
property LibLoader : load script file ((path to scripts folder from user domain as text) & "Libraries:Library Loader.scpt")
property TransmissionLib : LibLoader's loadScript("Libraries:Transmission.applescript")
property GrowlLib : LibLoader's loadScript("Libraries:Growl.applescript")
property SafariLib : LibLoader's loadScript("Libraries:Safari.applescript")
property DatesLib : LibLoader's loadScript("Libraries:Dates.applescript")