You need to sign in to do that
Don't have an account?
sanjaykumar
Retriving records
Hi All,
I am retrieving the records from opportunity line item schedule corresponding to the opportunity line item id, but there are multiple records in OpportunityLineItemSchedule corresponding to the one OpportunityLineItemId ..
I dont know how the compare the records available from the OpportunityLineItemSchedule with the OpportunityLineItemId and fetch the matched records and how to store them in an object.
Please help..
Thanks in Advance,
sanjay..
Can you precise what you would like to achieve?
Regards
qr = binding.query("select opportunityId,pricebookEntryId,Id from OpportunityLineItem");
} catch (UnexpectedErrorFault uef) {
System.out.println(uef.getExceptionMessage() + "\n\n");
return;
} catch (Exception e) {
e.printStackTrace();
System.out.println("\n\n");
return;
}
SObject[] records = qr.getRecords();
_opportunityLineItem = new OpportunityLineItem[records.length];
_opportunityLineItem[i] = opportunityLineItem;
System.out.println(" ");
System.out.println(" Opportunity ID - " + opportunityLineItem.getOpportunityId());
System.out.println(" Price Book Entry Id - " + opportunityLineItem.getPricebookEntryId());
System.out.println(" Opportunity Line Item Id - " + opportunityLineItem.getId());
SObject[] upsertobject = new GP_Calc__c[1];
GP_Calc__c upsertGP = new GP_Calc__c();
ID opportunityid = opportunityLineItem.getOpportunityId();
upsertGP.setOpportunity__c(opportunityid);
SObject[] sObjects = binding.retrieve("product2Id,name,pricebook2Id", "PricebookEntry", new ID[] {opportunityLineItem.getPricebookEntryId()});
if (sObjects != null) {
PricebookEntry pbe = (PricebookEntry) sObjects[j];
System.out.println(" Product 2 Id - " + pbe.getProduct2Id());
ID productid = pbe.getProduct2Id();
upsertGP.setProduct2__c(productid);
}
}
} catch (Exception ex) {
System.out.println("An unexpected error has occurred." + ex.getMessage());
}
try {
SObject[] sObject = binding.retrieve("revenue,scheduleDate,Id","OpportunityLineItemSchedule",new ID[] {opportunityLineItem.getId()});
if (sObject != null) {
for (int k = 0; k < 1; k++) {
System.out.println("Revenue - " + olis.getRevenue());
System.out.println("Scheduled Date - " + olis.getScheduleDate());
Double revenue = olis.getRevenue();
upsertGP.setGP_Amount__c(revenue);
Date scheduleDate = new Date(olis.getScheduleDate().getTime());
upsertGP.setSchedule_Date__c(scheduleDate);
ID externalid = olis.getId();
upsertGP.setExternal_ID__c(externalid);
}
} catch (Exception ex) {
System.out.println("An unexpected error has occurred." + ex.getMessage());
}
upsertobject[0] = upsertGP;
try {
if (upsertResults[0].isSuccess())
System.out.println("\nthe upsertion is a success\n");
else {
System.out.println("\nthe upsertion was a failure\n");
}
} catch (RemoteException ex) {
System.out.println("An unexpected error has occurred....." + ex.getMessage());
}
getUserInput("\nPress the RETURN key to continue...");
}
}
}