Four Stars

Deleting Sales Force Records Prior to insert

Hello!  I am relatively new to Talend.  I have successfully created a job that pulls filtered data from our AS400 and inserts into a custom Sales Force object in my Sandbox environment.  Now I need to create a step that deletes all records in the Sales Force custom object before the insert.  I was able to find several posts regarding this topic however none had solutions. So far I have a tSalesforceOutput component with the Output Action = DELETE.  Next is a tLogRow component (so I have a list of the record Ids).  Then a tSalesforceInput component.     I can execute the job without error but no records are deleted in Sales Force.  

 

Any assistance would be greatly appreciated.

 

cjsigler

1 ACCEPTED SOLUTION

Accepted Solutions
Thirteen Stars TRF
Thirteen Stars

Re: Deleting Sales Force Records Prior to insert

Hi,

You must know Salesforce Id for records you want to delete.

So, you need a tSalesforceInput to select these Id, then using tSalesforceOutput (or tSalesforceOutput if lot of records) you can delete the selected records. Just be careful to have Id as the only field in the schema for both components.

Here is the minimal job design for such a case:

tSalesforceInput --> tSalesforceOutput

 

Can you share your job?

 


TRF
15 REPLIES
Thirteen Stars TRF
Thirteen Stars

Re: Deleting Sales Force Records Prior to insert

Hi,

You must know Salesforce Id for records you want to delete.

So, you need a tSalesforceInput to select these Id, then using tSalesforceOutput (or tSalesforceOutput if lot of records) you can delete the selected records. Just be careful to have Id as the only field in the schema for both components.

Here is the minimal job design for such a case:

tSalesforceInput --> tSalesforceOutput

 

Can you share your job?

 


TRF
Four Stars

Re: Deleting Sales Force Records Prior to insert

So it sounds like I have my components backwards.  Not sure how to share the job so here is an image.

Untitled.png

 

 

Thirteen Stars TRF
Thirteen Stars

Re: Deleting Sales Force Records Prior to insert

Right, can you also share the schema for bot tSalesforceInput and Output components?
Also, does the tSalesforceInput select at least 1 record?

TRF
Four Stars

Re: Deleting Sales Force Records Prior to insert

Like this?

Untitled1.png

Four Stars

Re: Deleting Sales Force Records Prior to insert

That worked!!  I had my components backwards!  Thanks so much!!

Four Stars

Re: Deleting Sales Force Records Prior to insert

Untitled3.png

Thirteen Stars TRF
Thirteen Stars

Re: Deleting Sales Force Records Prior to insert

That's what I was going to tell you.

For best practice allways design your jobs from left to right and top to down.


TRF
Five Stars

Re: Deleting Sales Force Records Prior to insert

cjsigler, I'm trying to create a Delete job like yours, but not sure what  I'm doing wrong?

  • I created a setup like yours:
  • Capture.GIF
  • When I click run, I get the following error:
  • run_error.GIF
  • Am I missing something here? Do I need to use the tMap component too?
Five Stars

Re: Deleting Sales Force Records Prior to insert

My insert query/job works fine which uploads data from MySQL to my custom Salesforce object (see below):

- But how do I combine/add in the Delete option?

- I need to alter my job below to first do the Delete

- Then complete the Insert job

upload_mbs_to_salesforce.GIF

Thirteen Stars TRF
Thirteen Stars

Re: Deleting Sales Force Records Prior to insert

You need to use a tSalesforceInput component to select the id for the records you want to delete.
Then connect it to a tSalesforceOutput with DELETE operation selected.

TRF
Five Stars

Re: Deleting Sales Force Records Prior to insert

As I'm still learning Talend,

  1. How do I select the ID for the records to delete? 
  2. How do I combine this "Delete job" to my working "Insert job" above?

Here is what I have so far:

delete_mbs.GIF

Five Stars

Re: Deleting Sales Force Records Prior to insert

Ok, it looks like the Delete is running fine & deleted all of the MBS records in the custom object! Thanks for the help with that part!

- Now just one last question.. How do I add this "Delete Job" to my "Insert Job"?

- I need the delete to run first, then after the custom object is empty, run the Insert.

Thirteen Stars TRF
Thirteen Stars

Re: Deleting Sales Force Records Prior to insert

Just connect the tSalesforceInput component of the "delete" subjob with the 1rst component of the "insert" subjob using an onSubjobOk trigger.
Also don't forget to kudo the posts that help you. Much more better, open new posts for your questions.

TRF
Thirteen Stars TRF
Thirteen Stars

Re: Deleting Sales Force Records Prior to insert

Sounds like your problem is solved.

Thank's to close the topic.


TRF
Five Stars

Re: Deleting Sales Force Records Prior to insert

TRF, thanks again for the help.. this is an amazing tool when working between MySQL & Salesforce.

Here is my completed "DELETE then INSERT" job:

delete_insert_mbs_to_salesforce.GIF