How to create a new Lead using ForeignSysPersonId

Anonymous
Not applicable

How to create a new Lead using ForeignSysPersonId

I want to create leads based on a SFDC custome field say "Domain__c'
I am using JAVA SOAP API 2.0 for syncing the lead . Here is the sample code -

    HashMap<String, String> attrs = new HashMap<String, String>();
        attrs.put("FirstName", "Kir");
        attrs.put("LastName", "Gupta");
        attrs.put("Email" , "nc.c@abc.com");
        attrs.put("Company" , "isomecomapny");
        attrs.put("Domain_Name__c" , "domain1234");
        attrs.put("User_Name__c" , "K_user");
        LeadRecord leadRec = MktowsUtil.newLeadRecord(null,null,null, "Domain_Name__c", attrs);
        ResultSyncLead result = client.syncLead(leadRec, null, true);
       

// This is how I create a new record -
static public LeadRecord newLeadRecord(Integer Id, String Email, String fsysIdType, String fsysIdValue, HashMap<String, String> attributes) {
        
        LeadRecord lr = MktowsUtil.objectFactory.createLeadRecord();
        if (Id != null ) {
            lr.setId(Id);
        }
        if (Email != null) {
            lr.setEmail(Email);
        }
            
        lr.setForeignSysType(ForeignSysType.SFDC); // I set this yo SFDC , is it correct ?
        if(fsysIdValue!=null)
        {
            lr.setForeignSysPersonId(fsysIdValue);
        }
        if (attributes != null && attributes.size() > 0) {
            ArrayOfAttribute aoAttr = MktowsUtil.objectFactory.createArrayOfAttribute();
            List<Attribute> attrList = aoAttr.getAttribute();
            String attrName = null;
            Iterator<String> it = attributes.keySet().iterator();
            while (it.hasNext()) {
                attrName = it.next();
                attrList.add(MktowsUtil.newAttribute(attrName, attributes.get(attrName)));
            }
            lr.setLeadAttributeList(aoAttr);
        }
        return lr;
    }

Everytime I specify a new domain Name the same old lead gets updated. I cannot create new lead.  Can some one tell me what I am doing wrong ?  Also if possible can saome one provide me a sample code for using foriegnSysPersonId as unique key.


Thanks,
Neha
Tags (1)
2 REPLIES 2
Anonymous
Not applicable

Re: How to create a new Lead using ForeignSysPersonId

If both ForeignSysPersonId and the Marketo lead Id are present in the lead record, then the Marketo lead Id will take precedence and the ForeignSysPersonId will be updated. If the only ForeignSysPersonId is given, then it will be used as a unique identifier. 
 
The WSDL defines as
 
<xs:simpleType name="ForeignSysType">
<xs:restriction base="xs:string">
<xs:enumeration value="CUSTOM"/>
<xs:enumeration value="SFDC"/>
<xs:enumeration value="NETSUITE"/>
</xs:restriction>
</xs:simpleType>
 

ForeignSysType.SFDC is not set correctly. It needs to be defined as
<ForeignSysPersonId> </ForeignSysPersonId>
and
<ForeignSysType> </ForeignSysType>
 

Anonymous
Not applicable

Re: How to create a new Lead using ForeignSysPersonId

Thanks bgomes,

I am providing only ForeignSysPersonId in the lead record. No marketo id / SFDC id is present . I have a SFDC custom field "Domain_Name__c" this stores the domain name for a customer . I would like to use this custom field as ID.


<ForeignSysType> CUSTOM</ForeignSysType>
<ForeignSysPersonId> "Some Domain Name goes here "</ForeignSysPersonId>

the first lead gets created successfully , however for second lead when I pass another domainName still the first lead record gets updated instead of  creating a new Lead.