You need to sign in to do that
Don't have an account?
Inserting Account ID through API
my next question, i want to be able to set the account number the api gives me into the account number field, I have set the account number as "ID" but when i try to display it, it comes up blank. (because the definition of ID is defined after the input, but I cannot put it infront of it because it comes up with many errors) does any have code to display the account number in the correct field?
this is what my code looks like:
record[9] = new MapEntry();
record[9].setKey("accountNumber"); //Account Number
record[9].setValue(ID);
Element value = null;
value = (Element)binding.insert("account", record);
ID = XPathAPI.selectSingleNode(value, "/valueMap/id/text()").getNodeValue().toString();
System.out.println("Inserted new account, id: " + (ID) + ", with a name of AWilkinson");
System.out.println("");
If i could bring the Element value=null part above the record[9] new MapEntry() part, it would display fine, but it wont resolve symbol "record"
if anyone has code they could let me try, that would be greatly appreciated! thanks
record[9].setValue(XPathAPI.selectSingleNode(value, "/valueMap/id/text()").getNodeValue().toString());
but it comes out with the error:
java.lang.NullPointerException
at org.apache.xpath.XPathAPI.eval(XPathAPI.java:265)
at org.apache.xpath.XPathAPI.selectNodeIterator(XPathAPI.java:163)
at org.apache.xpath.XPathAPI.selectSingleNode(XPathAPI.java:124)
at org.apache.xpath.XPathAPI.selectSingleNode(XPathAPI.java:104)
at salesforce.Insert.runInsertDemo(Insert.java:144)
at salesforce.Insert.runDemo(Insert.java:62)
at salesforce.Insert.main(Insert.java:54)
Exception in thread "main" Process terminated with exit code 1
void runInsertDemo() throws DOMException, TransformerException, ServiceException, IOException {
if (loggedin == false)
{
runLoginDemo();
}
MapEntry[] record = new MapEntry[26];
// Test operation
record[9] = new MapEntry();
record[9].setKey("accountNumber"); //Account Number
record[9].setValue(ID);
Element value = null;
value = (Element)binding.insert("account", record); //this line.
ID = XPathAPI.selectSingleNode(value, "/valueMap/id/text()").getNodeValue().toString();
System.out.println("Inserted new account, id: " + (ID) + ", with a name of Joe Dickman");
System.out.println("");
getUserInput("Insert succeeded, hit enter to continue...");
}
void runInsertDemo() throws DOMException, TransformerException, ServiceException, IOException {
if (loggedin == false)
{
runLoginDemo();
}
MapEntry[] record = new MapEntry[26];
// Test operation
(records 10-25 here)
record[9] = new MapEntry();
record[9].setKey("accountNumber"); //Account Number
record[9].setValue(ID);
(records 0-8 here)
Element value = null;
value = (Element)binding.insert("account", record); //this line.
ID = XPathAPI.selectSingleNode(value, "/valueMap/id/text()").getNodeValue().toString();
System.out.println("Inserted new account, id: " + (ID) + ", with a name of Joe Dickman");
System.out.println("");
getUserInput("Insert succeeded, hit enter to continue...");
}
Hi AWilkinson,
Are you trying to create an account and insert the id into the accountNumber field in one pass? If so this won't work. What is ID set to when doing the insert?
ID = XPathAPI.selectSingleNode(value, "/valueMap/id/text()").getNodeValue().toString();
Message Edited by AWilkinson on 08-08-2003 10:51 AM