• Snehil22
  • 0 Points
  • Member since 2014

  • Chatter
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 2
  • 0
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.



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">
    <!--Zero or more repetitions:-->
        <urn:sObjects xsi:type="urn1:Contract_Sales_Order__c">   
        <urn1:Service_Maintenance_Contract__r xsi:type="urn1:SVMXC__Service_Contract__c">


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);
    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.
    i = i+1;