You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@camel.apache.org by "vassilis (JIRA)" <ji...@apache.org> on 2017/11/05 23:56:00 UTC

[jira] [Comment Edited] (CAMEL-10193) add support for lookup field using an sObject external id

    [ https://issues.apache.org/jira/browse/CAMEL-10193?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16239774#comment-16239774 ] 

vassilis edited comment on CAMEL-10193 at 11/5/17 11:55 PM:
------------------------------------------------------------

Hello all,

I just sent the above PR against 2.19.x, I hope it is of use :-)The implementation logic is as proposed by [~dhirajsb], in brief:

* If a field (
{noformat}
blng__Invoice__c
{noformat}
) of an object (blng__Payment__c) is a lookup field and points (blng__Invoice__c.blng__Payment__c --blng__Invoice__r--> blng__Invoice__c) to another object (blng__Invoice__c) that has at least one externaId (blng__Invoice__c.Invoice_External_Id__c), then a relationship field is generated as well.

* If an object (blng__Invoice__c) is used in at least one lookup field as the target object, then we generate also a Lookup object (blng__Invoice__c_Lookup) for that object (blng__Invoice__c).

E.g. 

{code:java}
public class blng__Payment__c extends AbstractDescribedSObjectBase {

    private static final SObjectDescription DESCRIPTION = createSObjectDescription();

    // blng__Invoice__c
    private String blng__Invoice__c;

    @JsonProperty("blng__Invoice__c")
    public String getblng__Invoice__c() {
        return this.blng__Invoice__c;
    }

    @JsonProperty("blng__Invoice__c")
    public void setblng__Invoice__c(String blng__Invoice__c) {
        this.blng__Invoice__c = blng__Invoice__c;
    }

    private blng__Invoice__c_Lookup blng__Invoice__r;
    
    @JsonProperty("blng__Invoice__r")
    public blng__Invoice__c_Lookup getblng__Invoice__r() {
        return this.blng__Invoice__r;
    }
    
    @JsonProperty("blng__Invoice__r")
    public void setblng__Invoice__r(blng__Invoice__c_Lookup blng__Invoice__r) {
        this.blng__Invoice__r = blng__Invoice__r;
    }
...
}
{code}


{code:java}
public class blng__Invoice__c_Lookup {
    private String Invoice_External_Id__c;

    @JsonProperty("Invoice_External_Id__c")
    public void setInvoice_External_Id__c(String e){
    	this.Invoice_External_Id__c = e;
    }
    
    @JsonProperty("Invoice_External_Id__c")
    public String getInvoice_External_Id__c(){
    	return this.Invoice_External_Id__c;
    }
}
{code}







was (Author: vassilis):
Hello all,

I just sent the above PR against 2.19.x, I hope it is of use :-)The implementation logic is as proposed by [~dhirajsb], in brief:

* If a field (blng__Invoice__c) of an object (blng__Payment__c) is a lookup field and points (blng__Invoice__c.blng__Payment__c --blng__Invoice__r--> blng__Invoice__c) to another object (blng__Invoice__c) that has at least one externaId (blng__Invoice__c.Invoice_External_Id__c), then a relationship field is generated as well.

* If an object (blng__Invoice__c) is used in at least one lookup field as the target object, then we generate also a Lookup object (blng__Invoice__c_Lookup) for that object (blng__Invoice__c).

E.g. 

{code:java}
public class blng__Payment__c extends AbstractDescribedSObjectBase {

    private static final SObjectDescription DESCRIPTION = createSObjectDescription();

    // blng__Invoice__c
    private String blng__Invoice__c;

    @JsonProperty("blng__Invoice__c")
    public String getblng__Invoice__c() {
        return this.blng__Invoice__c;
    }

    @JsonProperty("blng__Invoice__c")
    public void setblng__Invoice__c(String blng__Invoice__c) {
        this.blng__Invoice__c = blng__Invoice__c;
    }

    private blng__Invoice__c_Lookup blng__Invoice__r;
    
    @JsonProperty("blng__Invoice__r")
    public blng__Invoice__c_Lookup getblng__Invoice__r() {
        return this.blng__Invoice__r;
    }
    
    @JsonProperty("blng__Invoice__r")
    public void setblng__Invoice__r(blng__Invoice__c_Lookup blng__Invoice__r) {
        this.blng__Invoice__r = blng__Invoice__r;
    }
...
}
{code}


{code:java}
public class blng__Invoice__c_Lookup {
    private String Invoice_External_Id__c;

    @JsonProperty("Invoice_External_Id__c")
    public void setInvoice_External_Id__c(String e){
    	this.Invoice_External_Id__c = e;
    }
    
    @JsonProperty("Invoice_External_Id__c")
    public String getInvoice_External_Id__c(){
    	return this.Invoice_External_Id__c;
    }
}
{code}






> add support for lookup field using an sObject external id
> ---------------------------------------------------------
>
>                 Key: CAMEL-10193
>                 URL: https://issues.apache.org/jira/browse/CAMEL-10193
>             Project: Camel
>          Issue Type: New Feature
>          Components: camel-salesforce
>    Affects Versions: 2.17.2
>            Reporter: Satguru Srivastava
>            Assignee: Dhiraj Bokde
>
> A SalesForce object can have a field of type called "lookup". 
> This field is used to by a record in a SalesForce object to reference a record in another SalesForce object. 
> The value of this field could be a string in which case it would be the record id of the other record or it could be an object in which case it would contain the other Object's external field name and its value in that other record. 
> Doing lookup/reference by external id is very useful  specially for insert/upsert operations as otherwise one has to maintain record id of each of the records in the other Object.
> Camel SalesForce component supports lookup by record id. 
> There is no support for the second type that is the external field name and value type.
>  
> See here for more information on this 
> https://developer.salesforce.com/docs/atlas.en-us.api_rest.meta/api_rest/dome_upsert.htm
>  Section "Upserting Records and Associating with an External ID" 



--
This message was sent by Atlassian JIRA
(v6.4.14#64029)