• Snehil22
  • NEWBIE
  • 0 Points
  • Member since 2014

  • Chatter
    Feed
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 2
    Questions
  • 0
    Replies
I am trying to update a Custom object lookup using SOAP API by passing an external Id.

While doing that I am getting an error

Invalid foreign key relationship name Service_Maintenance_Contract__r

Service_Maintenance_Contract__c field is the lookup on SVMXC__Service_Contract__c object. Contract_Number__c is an external Id field on SVMXC__Service_Contract__c.

Note: I tried updating a Standard Object(Account) lookup using a similar process and it got updated successfully.

Wanted to know if there is a limitation with custom objects or is there any alternate way of doing this.

Thanks,

Snehil

Below is the SOAP request:
<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:urn="urn:enterprise.soap.sforce.com" xmlns:urn1="urn:sobject.enterprise.soap.sforce.com" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
   <soapenv:Header>
      
      <urn:SessionHeader>
         <urn:sessionId>00Dn0000000DmLK!ARYAQHnxa1gCV5u6I8AH4fhdrweGU43ysYtYt6Rf7TAdN1NhSQcaw_4FdxCgbR9pUqTLiVW4zlHs5PDITFevblyPg44RCAKRF</urn:sessionId>
      </urn:SessionHeader>
   </soapenv:Header>
   <soapenv:Body>
      
      <urn:create>
    <!--Zero or more repetitions:-->
 
        <urn:sObjects xsi:type="urn1:Contract_Sales_Order__c">   
        <urn1:Oracle_Sales_Order_Number__c>54321</urn1:Oracle_Sales_Order_Number__c>
                         
        <urn1:Service_Maintenance_Contract__r xsi:type="urn1:SVMXC__Service_Contract__c">
        <Contract_Number__c>21312033</Contract_Number__c>
        </urn1:Service_Maintenance_Contract__r>
       
      </urn:sObjects>
      </urn:create>
   </soapenv:Body>
</soapenv:Envelope>

 
Hi,

In the below code, I am trying to send one header(Account) and multiple lines(Case). I am querying cases and adding it to a list(caseObj). The method which i am calling in the main class requires 2 parameters(String,List), so I am adding multiple cases in a list(ListLines).

The issue is that the list is getting the latest values and not the values of all the queried records. Please Help.

public class WMTestWebservice{
 
@future(callout = true)
    public static void WMTest(set<string> psoid){
   
        Account accObj=[select id,Name
                   
        from Account where Id=:psoid];
       
             
        List<Case> caseObj=[select id,Subject
                   
        from Case where Account.Id=:psoid];
             
      
    wmAppDev02AmHealthGeComSnehilPa.Snehil_Parts_Port  mainClass = new wmAppDev02AmHealthGeComSnehilPa.Snehil_Parts_Port ();
           
    wmAppDev02AmHealthGeComSnehilPa.Header header = new wmAppDev02AmHealthGeComSnehilPa.Header();
   
    wmAppDev02AmHealthGeComSnehilPa.Lines line = new wmAppDev02AmHealthGeComSnehilPa.Lines();
   
    List<wmAppDev02AmHealthGeComSnehilPa.Lines> ListLines = new wmAppDev02AmHealthGeComSnehilPa.Lines[150];
     
   
   
    mainClass.inputHttpHeaders_x = new Map<String, String>();

    String myCred1 = '******';
    String myCred2 = '******';
   
    Blob headerValue = Blob.valueOf(myCred1+':'+myCred2);
    String authorizationHeader = 'Basic ' +EncodingUtil.base64Encode(headerValue);
 
    mainClass.inputHttpHeaders_x.put('Authorization',authorizationHeader);
    mainClass.timeout_x=120000;
       
       
    header.name = accObj.Name;
    header.id   = accObj.id;
  
    integer i=0;
   
    for(Case cs: caseObj){ 
    
    line.EID    = cs.id;
    line.laptop = cs.Subject;
                   
    ListLines.add(i,line);// I am adding multiple cases in this list.
   
    system.debug('<<<<<ListLinesInsideLoop<<<<<'+ListLines);
   
    i = i+1;
      
     }
             
    system.debug('<<<<<ListLines<<<<<'+ListLines);   
    
   
    mainClass.ProcessPartOrder(header,ListLines);
       
   
   
    }
       
  }