[SDK17] Calling Objective-C code and getting a return

Discussion created by sfpx on Nov 10, 2018
Latest reply on Nov 11, 2018 by fmpdude

I would love to know if there is a simpler way to achieve this.


I converted my filemaker plugin into code that I call with a second url scheme intercepted in a custom appdelegate.m file.


It works well.


Now I'm trying to call code and to get a return in filemaker.

I got it to work this way.


Filemaker Script "MyScript"

If [ not($$DataRequested) ]

     Set Variable [ $$DataRequested ; Value: 1 ]

     Open URL [With Dialog: Off ; "myappf://add?ReturnScript=MyScript&number1=5&number2=7" ]


     If [ not(IsEmpty($DATA)) ]

          Show Custom Dialog [$DATA]

     End If    

     Set Variable [$$DataRequested ; Value: "" ]

End If


In the appdelegate.m file

- (BOOL)application:(UIApplication *)app

openURL:(NSURL *)url

options:(NSDictionary<UIApplicationOpenURLOptionsKey, id> *)options


NSURLComponents *urlComponents = [NSURLComponents componentsWithURL:url resolvingAgainstBaseURL:NO];

NSArray *queryItems = urlComponents.queryItems;

if ([[url scheme] isEqualToString:@"myappf"])


     NSString *Operation=[url host];

     if ([Operation isEqualToString:@"add"])


         int number1=[[self valueForKey:@"number1" fromQueryItems:queryItems] doubleValue];

         int number2=[[self valueForKey:@"number2" fromQueryItems:queryItems] doubleValue];

         NSString *ReturnScript=[self valueForKey:@"ReturnScript" fromQueryItems:queryItems];

         double result=number1+number2;

         NSString *param=[NSString stringWithFormat:@"%f;%@",result,ReturnScript];

         NSDictionary *dict = @{@"$Data":[NSString stringWithFormat:@"%f",result]};

         FMX_Queue_Script([[NSBundle mainBundle] objectForInfoDictionaryKey:@"LaunchSolutionKey"],ReturnScript,kFMXT_Resume,param,dict);



return YES;



So basically, the script will call the appdelegate code which will execute the same script again but with the variable $DATA set.

More validation is needed but you get the gist.


I was wondering if there was a simpler way (without using a filemaker plugin).


It works but it's certainly far from an ideal solution...especially if you need to call a lot of functions inside the same script .