I am trying to insert data in salesforce using upsert, for one field i am using the ExternalId field , i have tried many combinations but it fails...I get the error : the syntax should be object:externalId/lookupField
Any idea what is the exact syntax? Keep in mind i am inserting in table Account and the externalId field refers to Account also
object:externalId/lookupField is not very clear is it. There's a comment hidden away in the Pentaho code:
// We use an external key
// the structure should be like this :
// object:externalId/lookupField
// where
// object is the type of the object
// externalId is the name of the field in the object to resolve the value
// lookupField is the name of the field in the current object to update (is the "__r" version)
Lets say you're populating a Salesforce Object Foo__c, which has a Lookup field to Contact called Contact__c. The 'relationship name' for that lookup field would then be Contact__r.
On Contact lets say you have added an External ID called Legacy_Id__c and thats what you want to use when populating Foo__c.
What Pentaho would want in the Module Field column would then be:
Contact:Legacy_Id__c\Contact__r
The bit to the left of the slash is telling Pentaho which object/external id to map to. To the right of the slash, its telling Pentaho which lookup/relationship on Foo__c to fill in.
Related
A client has created a custom object call CustObj__c in Salesforce. They have required fields , one is Cust_Id which is of type Formula (Text)
I am trying to create a Custom Object item using the following
List<CustObj__c> CustList = new List<CustObj__c>();
CustObj__c Item_0 = new CustObj__c( Name__c='TEST1', Cust_Id='Cust: '& 123);
CustList.add(Item_0);
CustObj__c Item_1 = new CustObj__c( Name__c='TEST2', CustId__c='Cust: '& 456);
CustList.add(Item_1);
insert CustList;
But it gives the error that
Field is not writeable: CustObj__c.CustId__c
How can i insert if the field is non writeable but required ?
If it is a custom metadata object , do i need to do this ?
client hasnt provided any details
Formula fields are calculated at runtime when you view the record and are readonly, can't be marked as required. If your client has business need for it to be required they probably created a validation rule that checks the field value.
You'll have to inspect the field's formula and insert data that would satisfy it. (Some other fields populated, maybe some dates or right amounts). Maybe they assign customer id(?) in some special way, only if account reaches certain status, moves from prospect to paying customer.
You could ask them if they ever had to write unit tests that insert these records and steal get inspired by these code samples, see what prerequisites there are or fields that impact that formula.
I need to do 1 of two things (I believe):
1- Get a Custom Object ID so I can query it directly
2- Get a list of values of a specific field within the Object entries.
Ultimate End goal:
Add and modify rows in my custom object via external API. However to do this I need to check and make sure my new entry/row does not already exist.
What I have:
I have a custom object (called Customer_Arrays__c). It is a table that I can add new rows to (I will call entrys). Each entry has 6 or 7 fields. 1 of these fields is called (external_ID__c). This is the field I utilize to match to new incoming data to see if the entry already exists, or if it needs to add a new row to my table. This Customer_Arrays__c is a child to my opportunity I believe – it is part of every opportunity and each line item I add has a field defaulted to the opportunity.
Help I need:
1- How do I query the value of my Cutomer_Arrays__c based upon an opportunity ID?
2- How do I query a list of values in my (external_ID__c) based upon an opportunity ID?
Thanks for your help! I have read half a dozen+ posts on similar topics and am missing something. Examples of some Past try's that failed:
Select external_ID__c,FROM Custom_Arrays__c WHERE Opportunity='00...'
Select Id (Select ID, Custom_Arrays__c from Custom_Arrays__c) from Opportunity where id ='00...'
List FROM Custom_Arrays__c WHERE Opportunity='00...'
Select Id, external_ID__c, (Select external_ID__c FROM Custom_Arrays__c) WHERE Opportunity__c='00...'
Thanks again!
Only you know how did you name the lookup field (foreign key) from arrays to Opportunity. You'll need to check in setup, next to where external_ID__c is. Since it's a custom field (gets __c at the end), my guess is you went with default.
Try
SELECT Id, Name, External_Id__c
FROM Customer_Arrays__c
WHERE Opportunity__c = '006...'
Thank you eyescream, that got me almost all the way there. Turns out I also needed a __r for the parent child relationship.
Here is a snip out of my final code that works - I think it covers everything:
SELECT Field1__c, Opportunity__r.Id, Opportunity__r.Opportunity__c,
FROM Customer_Arrays__c
WHERE Opportunity__r.Id = '006...'.
Thank you so very much!!!
i have two objects KNDY4__Sales_Order__c and KNDY4__Bill_to__c.these two are linked through lookup relationship.i am trying to insert one order record as follows
`KNDY4__Sales_Order__c order=New KNDY4__Sales_Order__c();
order.KNDY4__Ship_to__c ='a14q0000001LnIeAAK';
order.KNDY4__Bill_to__r.Predicted_External_ID__c ='CN-0222741-Sold To';
order.KNDY4__Company__c ='a0l1N00000BQQKF';
Insert order;`
i am geting error as {"Object reference not set to an instance of an object."}.
how to assign values to lookup field.can anyone help me
When linking a record based on an external id, the relationship field needs to be set to an sObject with the external id, and not just the value of the id itself.
On line 3, since KNDY4__Bill_to__c is a lookup field to a custom object possibly named KNDY4__Customer__c, you should set the value of the lookup to an instance of that object, e.g.
order.KNDY4__Bill_to__r = new KNDY4__Customer__c(KNDY4__Predicted_External_ID__c ='CN-0222741-Sold To');
I have a salesforce query that extracting users time report
SELECT ID,Logged_Date__c ,CreatedBy.Email, CreatedBy.id, CreatedBy.Name, Time_Spent_Hours__c, Activity__c, CaseId__r.CaseNumber, CaseId__r.Account.id, CaseId__r.Account.Name , Utilized__c
FROM Time_and_Placement_Tracking__c
The Activity__c returns with the activity text.
I was trying to use Activity__c.Id, Activity__r etc. but all returns with error.
Is there a way to get the Activity id?
Verify these
You need to get to the object definition and see the field info. You can use workbench or any other API tool if you are familiar with and get the object and field def's.
Check the data type for Activity__c field. It should be a lookup/master relation. If it is not, find the field which ties to Activity object.
Open the field to get the API name and use that in the query with a '__r' extension.
I am using ADF JDeveloper 11g Release 2
I am using Entity object called Project referring to actual database table. This table contains fileds that hold abbreviation values; for example this table have filed called STATUS that describe the current status for the project. this filed will have values like: 'A' for Approved, 'X' for Rejected, and so on.
In the interface( JSPX, or JSF Pages) I am just drag and drop the View object that refers to the Project Entity object. and the page will display the project records with their status as specified.
Question is:
Is there any way to change this observation values to the actual value somewhere; That is, Instead of having values like ( A, X,...) I want to have ( Approved, Rejected,...)
You can create a transient attribute at VO level. In the value of this attribute you can write groovy expression which will use the value of attribute named status and decode it.
Alternatively, you can alter the VO query using DECODE function by doing something like this :
SELECT name and other fields needed,
DECODE(status, 'A', 'Approved',
'X', 'Rejected',
'P', 'Pending',
'Default') decodedstatus
FROM projects;
You will need to have an additional attribute in VO in this case and can directly use the value returned by VO in UI.