AnsweredAssumed Answered

How to create a new Lead using ForeignSysPersonId

Question asked by 049f04d17600c0c4a0c8413c607f986c88c764d3 on Sep 17, 2013
Latest reply on Sep 18, 2013 by 049f04d17600c0c4a0c8413c607f986c88c764d3
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" , "");
        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 ) {
        if (Email != null) {
        lr.setForeignSysType(ForeignSysType.SFDC); // I set this yo SFDC , is it correct ?
        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 =;
                attrList.add(MktowsUtil.newAttribute(attrName, attributes.get(attrName)));
        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.