SalesforceXyToolsCore/Python上でSalesforce組織からのPackage.xmlを作成

Topic

Package.xmlの作成

  • Salesforce組織のユーザ名、パスワード、Apiバージョン、Product/Sandboxを設定してください。
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
from SalesforceXytoolsCore import *
import pprint
config = {
"api_version": 42.0,
"username": "sfdc username",
"password": "sfdc password",
"security_token": "",
"is_sandbox": True
}
meta_api = MetadataApi(username=config["username"],
password=config["password"],
security_token=config["security_token"],
sandbox=config["is_sandbox"],
version=config["api_version"]
)
"""buildPackageXml"""
packagexml = meta_api.buildPackageXml()

結果確認:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
<?xml version="1.0" encoding="UTF-8"?>
<Package xmlns="http://soap.sforce.com/2006/04/metadata">
<types>
<members>*</members>
<name>InstalledPackage</name>
</types>
<types>
<members>*</members>
<name>CustomLabels</name>
</types>
....................
........省略.........
....................
<types>
<members>Account</members>
<members>AccountChangeEvent</members>
<members>AccountCleanInfo</members>
<members>AccountContactRole</members>
<members>AccountFeed</members>
<members>AccountHistory</members>
<members>AccountPartner</members>
<members>AccountShare</members>
<members>ActionLinkGroupTemplate</members>
<members>ActionLinkTemplate</members>
<members>ActivityHistory</members>
<members>AdditionalNumber</members>
<members>AggregateResult</members>
....................
........省略.........
....................
<name>CustomObject</name>
</types>
<types>
<members>unfiled$public</members>
....................
........省略.........
....................
<members>unfiled$public/SupportCaseAssignmentNotification</members>
<members>unfiled$public/SalesNewCustomerEmail</members>
<members>unfiled$public/SupportCaseCreatedWebInquiries</members>
<members>unfiled$public/SupportEscalatedCaseNotification</members>
<members>unfiled$public/SupportSelfServiceResetPassword</members>
<members>unfiled$public/MarketingProductInquiryResponse</members>
<members>unfiled$public/SupportCaseCreatedPhoneInquiries</members>
<members>unfiled$public/SUPPORTSelfServiceResetPasswordSAMPLE</members>
<members>unfiled$public/SupportEscalatedCaseReassignment</members>
<members>unfiled$public/SUPPORTSelfServiceNewCommentNotificationSAMPLE</members>
<name>EmailTemplate</name>
</types>
....................
........省略.........
....................
<types>
<members>*</members>
<name>TopicsForObjects</name>
</types>
<types>
<members>*</members>
<name>EmailServicesFunction</name>
</types>
<types>
<members>*</members>
<name>Settings</name>
</types>
<version>42.0</version>
</Package>

SFDC組織からPackage関するリストを取得

1
2
3
"""packageTypeList"""
print('>>>packageTypeList')
pprint.pprint(meta_api.packageTypeList())

結果確認

1
2
3
4
5
6
7
8
9
10
[{'members': ['*'], 'name': 'InstalledPackage'},
{'members': ['*'], 'name': 'CustomLabels'},
{'members': ['*'], 'name': 'StaticResource'},
....................
........省略.........
....................
{'members': ['*'], 'name': 'TopicsForObjects'},
{'members': ['*'], 'name': 'EmailServicesFunction'},
{'members': ['*'], 'name': 'Settings'}]