You need to sign in to do that
Don't have an account?

can't create sobject getting error trying to set Account_r?
So, I have an sobject we call time that keeps track of time spent doing tasks thru the day. I have one field in the object that sets the relationship to the particular account we are timing
Time__c newTime = new Time__c();
newTime.setStart_Date_and_Time__c(startTime);
newTime.setStop_Date_and_Time__c(stopTime);
newTime.setTime_Description__c(timeDescription);
newTime.setVulnClass__c(vulnClass);
newTime.setAccount__r(account.getAccount__r()); <=========== error here this method takes an sobject.account
/**
* Sets the account__r value for this Time__c.
*
* @param account__r
*/
public void setAccount__r(com.sforce.soap.enterprise.sobject.Account account__r) {
this.account__r = account__r;
}
This is the error i get when i try to update:
The error reported was: Field name provided, Name is not an External ID or indexed field for Account
This is my query to get the info:
Select Name,Account__r.Name,Site__r.Name from Site_Workflow__c where OwnerId ='000000000000000' and Account__r.Name= 'account name string' and Site__r.Name ='site string here'
Simon thanks for getting back to me so quickly. However I do not understand what you mean by external id or fk(foriegn key. I have these method
/**
* Sets the account__c value for this Time__c.
*
* @param account__c
*/
public void setAccount__c(java.lang.String account__c) {
this.account__c = account__c;
}
/**
* Sets the account__r value for this Time__c.
*
* @param account__r
*/
public void setAccount__r(com.sforce.soap.enterprise.sobject.Account account__r) {
this.account__r = account__r;
}
I have this as my error call:
newTime.setAccount__r(account.getAccount__r());
account.getAccount__r().getClass gives me com.sforce.soap.enterprise.sobject.Account so the parameter seems to be correct.
Here are thge instance variables of time
==================
private com.sforce.soap.enterprise.sobject.Account account__r;
private com.sforce.soap.enterprise.QueryResult activityHistories;
private com.sforce.soap.enterprise.QueryResult attachments;
private java.lang.String case__c;
private com.sforce.soap.enterprise.sobject._case case__r;
private com.sforce.soap.enterprise.sobject.User createdBy;
private java.lang.String createdById;
private java.util.Calendar createdDate;
private com.sforce.soap.enterprise.QueryResult events;
private com.sforce.soap.enterprise.QueryResult histories;
private java.lang.Boolean isDeleted;
private java.util.Date lastActivityDate;
private com.sforce.soap.enterprise.sobject.User lastModifiedBy;
private java.lang.String lastModifiedById;
private java.util.Calendar lastModifiedDate;
private java.lang.Double minutes_Spent__c;
private java.lang.String name;
private com.sforce.soap.enterprise.QueryResult notes;
private com.sforce.soap.enterprise.QueryResult notesAndAttachments;
private java.lang.String notes_Details__c;
private com.sforce.soap.enterprise.QueryResult openActivities;
private com.sforce.soap.enterprise.sobject.Name owner;
private java.lang.String ownerId;
private com.sforce.soap.enterprise.QueryResult processInstances;
private com.sforce.soap.enterprise.QueryResult processSteps;
private java.lang.String site_Work_Flow__c;
private com.sforce.soap.enterprise.sobject.Site_Workflow__c site_Work_Flow__r;
private java.lang.String site__c;
private com.sforce.soap.enterprise.sobject.Site__c site__r;
private java.util.Calendar start_Date_and_Time__c;
private java.util.Calendar stop_Date_and_Time__c;
private java.util.Calendar systemModstamp;
private com.sforce.soap.enterprise.QueryResult tasks;
private java.lang.String time_Description__c;
private java.lang.String vulnClass__c;
====================
there is no external id to set? Please could you clarify what might be happening?
All Answers
Either set the externalId value in the account object, or set the FK field to the salesforce.com account Id. e.g.
newTime.setAccount__c(someAccountId);
Simon thanks for getting back to me so quickly. However I do not understand what you mean by external id or fk(foriegn key. I have these method
/**
* Sets the account__c value for this Time__c.
*
* @param account__c
*/
public void setAccount__c(java.lang.String account__c) {
this.account__c = account__c;
}
/**
* Sets the account__r value for this Time__c.
*
* @param account__r
*/
public void setAccount__r(com.sforce.soap.enterprise.sobject.Account account__r) {
this.account__r = account__r;
}
I have this as my error call:
newTime.setAccount__r(account.getAccount__r());
account.getAccount__r().getClass gives me com.sforce.soap.enterprise.sobject.Account so the parameter seems to be correct.
Here are thge instance variables of time
==================
private com.sforce.soap.enterprise.sobject.Account account__r;
private com.sforce.soap.enterprise.QueryResult activityHistories;
private com.sforce.soap.enterprise.QueryResult attachments;
private java.lang.String case__c;
private com.sforce.soap.enterprise.sobject._case case__r;
private com.sforce.soap.enterprise.sobject.User createdBy;
private java.lang.String createdById;
private java.util.Calendar createdDate;
private com.sforce.soap.enterprise.QueryResult events;
private com.sforce.soap.enterprise.QueryResult histories;
private java.lang.Boolean isDeleted;
private java.util.Date lastActivityDate;
private com.sforce.soap.enterprise.sobject.User lastModifiedBy;
private java.lang.String lastModifiedById;
private java.util.Calendar lastModifiedDate;
private java.lang.Double minutes_Spent__c;
private java.lang.String name;
private com.sforce.soap.enterprise.QueryResult notes;
private com.sforce.soap.enterprise.QueryResult notesAndAttachments;
private java.lang.String notes_Details__c;
private com.sforce.soap.enterprise.QueryResult openActivities;
private com.sforce.soap.enterprise.sobject.Name owner;
private java.lang.String ownerId;
private com.sforce.soap.enterprise.QueryResult processInstances;
private com.sforce.soap.enterprise.QueryResult processSteps;
private java.lang.String site_Work_Flow__c;
private com.sforce.soap.enterprise.sobject.Site_Workflow__c site_Work_Flow__r;
private java.lang.String site__c;
private com.sforce.soap.enterprise.sobject.Site__c site__r;
private java.util.Calendar start_Date_and_Time__c;
private java.util.Calendar stop_Date_and_Time__c;
private java.util.Calendar systemModstamp;
private com.sforce.soap.enterprise.QueryResult tasks;
private java.lang.String time_Description__c;
private java.lang.String vulnClass__c;
====================
there is no external id to set? Please could you clarify what might be happening?