savestate
This commit is contained in:
@ -0,0 +1,47 @@
|
||||
import os
|
||||
import argparse
|
||||
from sys import path
|
||||
path.append('../..')
|
||||
from sf_auth import get_sf_connection
|
||||
|
||||
def insert_service_contracts(context):
|
||||
"""
|
||||
Insert ServiceContract records using Bulk API 2.0
|
||||
|
||||
Args:
|
||||
context (str): Salesforce org context (e.g., 'qa2', 'prod')
|
||||
"""
|
||||
try:
|
||||
# Get Salesforce connection
|
||||
sf = get_sf_connection(context)
|
||||
|
||||
csv_file = 'ServiceContract.csv'
|
||||
print(f'Starting bulk insert of ServiceContract records from {csv_file}...')
|
||||
|
||||
# Use bulk API 2.0 to insert records directly from CSV
|
||||
results = sf.bulk2.ServiceContract.insert(
|
||||
csv_file,
|
||||
batch_size=10000,
|
||||
concurrency=5
|
||||
)
|
||||
|
||||
# Count successes and failures
|
||||
success_count = sum(1 for result in results if result['success'])
|
||||
total_count = len(results)
|
||||
|
||||
print(f'\nInsertion complete:')
|
||||
print(f'Total records: {total_count}')
|
||||
print(f'Successful: {success_count}')
|
||||
print(f'Failed: {total_count - success_count}')
|
||||
|
||||
except Exception as e:
|
||||
print(f'Error: {str(e)}')
|
||||
raise
|
||||
|
||||
if __name__ == '__main__':
|
||||
parser = argparse.ArgumentParser(description='Insert ServiceContract records via Bulk API')
|
||||
parser.add_argument('--context', type=str, required=True,
|
||||
help='Salesforce org context (e.g., "qa2", "prod")')
|
||||
|
||||
args = parser.parse_args()
|
||||
insert_service_contracts(args.context)
|
@ -0,0 +1,4 @@
|
||||
ObjectName,FieldName,RawValue,Value
|
||||
ServiceContract,Status,Active,Active
|
||||
ServiceContract,Status,Cancelled,Inactive
|
||||
ServiceContract,Status,Created,Active
|
|
1
prepared_steps/15_insert_servicecontract/command.txt
Normal file
1
prepared_steps/15_insert_servicecontract/command.txt
Normal file
@ -0,0 +1 @@
|
||||
sf sfdmu run --sourceusername rene.kasseboehmer@vaillant.de.devrene --targetusername rene.kasseboehmer@vaillant.de.devrene
|
23
prepared_steps/15_insert_servicecontract/export.json
Normal file
23
prepared_steps/15_insert_servicecontract/export.json
Normal file
@ -0,0 +1,23 @@
|
||||
{
|
||||
"allOrNone": true,
|
||||
"excludeIdsFromCSVFiles": true,
|
||||
"objects": [
|
||||
{
|
||||
"query": "SELECT Id FROM Pricebook2 WHERE Name LIKE 'NL%'",
|
||||
"operation": "Readonly",
|
||||
"externalId": "Id",
|
||||
"master": false
|
||||
},{
|
||||
"query": "SELECT Id FROM Account WHERE BillingCountry__c = 'NL'",
|
||||
"operation": "Readonly",
|
||||
"externalId": "Id",
|
||||
"master": false
|
||||
},{
|
||||
"query": "SELECT PKey__c,Status,BillingCountryCode,AccountId,Service_Recipient__c,IoT_Registration_Status__c,Pricebook2Id, TemplateId__c FROM ServiceContract",
|
||||
"operation": "Insert",
|
||||
"useValuesMapping": true,
|
||||
"useSourceCSVFile": true,
|
||||
"master": true
|
||||
}
|
||||
]
|
||||
}
|
Reference in New Issue
Block a user