Community Tip - If community subscription notifications are filling up your inbox you can set up a daily digest and get all your notifications in a single email. X
Hi Everyone,
I'm trying to call a service whose name will be stored in a variable. For example, here's how I would normally call the service GetJobOrder:
let params = {UID: '7'};
const result = me.GetJobOrder(params);
However, I want to be able to execute a service if the service name is stored in a variable rather than explicitly typed out. For example, this is what I've tried:
let scriptName = 'GetJobOrder';
let params = {UID: '7'};
const result = me.svc[scriptName](params);
I wasn't able to get this to work as shown below:
I tried various ways to try to call the service but none were successful:
Does anyone know if this is possible? How can I call a service when the service name is stored in a variable, rather than explicitly specifying the service name?
Thanks for your help.
Andrew
Solved! Go to Solution.
var scriptName = 'GetJobOrder';
var params = {UID: '7'};
var result = me[scriptName](params);
Like this
var scriptName = 'GetJobOrder';
var params = {UID: '7'};
var result = me[scriptName](params);
Like this
Perfect, that did the trick! Thanks a bunch for your help, much appreciated.