David B
11/18/2022, 3:27 AM.envType
.
However I'm getting the error SUITESCRIPT_API_UNAVAILABLE_IN_DEFINE
. My instinct is to wrap it up in a 'getConfig' function, but it feels wrong.
Is there a way I can set this up so I can still do this:David B
11/18/2022, 3:31 AMbattk
11/18/2022, 4:21 AMbattk
11/18/2022, 4:22 AMerictgrubaugh
11/18/2022, 7:23 AMShawn Talbert
11/18/2022, 7:32 PMerictgrubaugh
11/19/2022, 12:01 AMShawn Talbert
11/19/2022, 1:20 AMconfig.js
in your deploy.xml
simply copying config_sb1.js
or config_prod.js
to config.js
prior to running the deploy. It helps keep the configs declarative (no if sandbox else blah
sort of imperative logic.Shawn Talbert
11/19/2022, 1:23 AMShawn Talbert
11/19/2022, 1:27 AMerictgrubaugh
11/19/2022, 1:34 AMbattk
11/19/2022, 4:29 AMerictgrubaugh
11/19/2022, 5:00 PMbattk
11/19/2022, 6:05 PMbattk
11/19/2022, 6:06 PMbattk
11/19/2022, 6:08 PMbattk
11/19/2022, 6:13 PMDavid B
11/21/2022, 9:11 PMerictgrubaugh
11/21/2022, 10:07 PMclass ApprovalList {
get REJECTED() {
return (runtime.envType === runtime.EnvType.PRODUCTION) ? 4 : 3;
}
get CANCELED() {
return (runtime.envType === runtime.EnvType.PRODUCTION) ? 3 : 4;
}
}
one could just use plain ol' Objects to map Account ID to value:
class ApprovalList {
get REJECTED() {
return ({
'12345678': 4,
'12345678_SB1': 3,
'12345678_SB2': 5,
})[runtime.accountId];
}
get CANCELED() {
return ({
'12345678': 3,
'12345678_SB1': 4,
'12345678_SB2': 5,
})[runtime.accountId];
}
}
Gets a bit repetitive, and I'd probably make an enumeration module for the Account IDs themselves as well, but it's workable. I'm also playing around with Proxy
now, which I wasn't aware of previously.Shawn Talbert
11/21/2022, 10:54 PMShawn Talbert
11/21/2022, 10:57 PMDavid B
11/21/2022, 10:59 PMDavid B
11/21/2022, 11:05 PMenum.REJECTED[runtime.accountid]
, seems a pain[runtime.accountId]
at the end facepalm
I think I've got this proxy right:erictgrubaugh
11/22/2022, 12:47 AMProxy
. The keys of my configEnums
were the Account IDs and the values were the config Objects. Then my Proxy
handler was:
get(target, prop, receiver) {
return target[runtime.accountId]?.prop;
}
battk
11/22/2022, 5:01 AMerictgrubaugh
11/22/2022, 5:09 AMbattk
11/22/2022, 5:10 AMbattk
11/22/2022, 5:15 AMbattk
11/22/2022, 5:16 AM