Salesforce 支持不同的沙盒。
例如“部分”或“开发”沙箱。
有没有办法检测我的脚本连接到哪种沙箱?
我使用 Python 和 simple_salesforce。
Salesforce 支持不同的沙盒。
例如“部分”或“开发”沙箱。
有没有办法检测我的脚本连接到哪种沙箱?
我使用 Python 和 simple_salesforce。
我的 Python 还不够好。我可以给出提示,但你必须自己尝试一下。
https://github.com/simple-salesforce/simple-salesforce “附加功能”表示有内部类可以向您公开 session_id 和实例。
您可以使用这些来制作 HTTP GET 调用以
Authorization: Bearer {session_id}
{instance}/services/data/v51.0/limits
“限制”资源将告诉您(除其他外)该组织中可用的数据和文件存储是什么。它将返回一个类似于
{
...
"DataStorageMB" : {
"Max" : 200,
"Remaining" : 196
},
...
}
使用https://help.salesforce.com/articleView?id=sf.data_sandbox_environments.htm&type=5DataStorageMB.Max
底部的表格来确定您的位置。200 => 开发人员,1024 => 开发人员专业...
编辑 - 如果您使用 Apex(可能作为 REST 服务公开,“简单的销售人员”有很好的内置访问它们)
Integer storageLimit = OrgLimits.getMap().get('DataStorageMB').getLimit();
System.debug(storageLimit);
String sandboxType;
switch on storageLimit{
when 200 {
sandboxType = 'Developer';
}
when 1024 {
sandboxType = 'Developer Pro';
}
when 5120 {
sandboxType = 'Partial Copy';
}
when else {
sandboxType = 'Full Copy';
}
}
System.debug(sandboxType);