Is there a way we can access the workspace name inside the custom functions like Master,Staging,
Development?.
Hey @skiran!
You can get it from FunctionContext like this ctx.environmentName
Docs reference functions-types/index.d.ts at master · 8base/functions-types · GitHub
I tried this but it returns undefined
Hello skiran, can you show a screenshoot of how are you testing/running the custom function?
Hi @igor.solovyov
When I logged the context object and it was only printing Context Object {"api":{},"workspaceId":"my workspace id"}
but not the environment name. also i logged context.environmentName
it was printing undefined
@rey No I was not able to resolve this. as a work around we created a environment variable in each branch and validating in the custom functions to check the env
Hi @igor.solovyov below is my custom function
module.exports = async (event, ctx) => {
//some logic
return {
data: {
...event.data
},
errors: []
}
}
Hi @skiran, can you confirm, is this the result you get when invoking the function locally with invoke-local
or do you get this result when the function is executed on the server?
Hi @rey ,
You are right I am able to get the environment name on the server but not when i invoke the function locally. Thank you.