+ Start a Discussion
Roshan TamrakarRoshan Tamrakar 

Random name for relationship name

Hi experts,

I wanted to have a many-to-many relationship between Asset and a custom object SP__c. For that I created a custom object Program_Asset__c. I added two lookup fields in it, one related to Asset and other related to SP__c. When I checked it in Apex Explorer, the child relationship name in Asset is some odd number and not in readable form (should have been Program_Assets__r). The highlighted item is the one.



Because of this my deployment fails in other org because it is used in my soql query and new package installation creates another random name for the relationship.

Code:
Select Id, (Select SP__c, SP__r.Name From a.R00N30000002NWqzEAG) From Asset a Where a.Id ='02i30000001DcJa'
 
What went wrong?

Also, How do I know from apex class that I am currently in 'Desktop' page (console tab): https://na1.salesforce.com/ui/desktop/DesktopPage

Please help me.

Thanks,
-Roshan
A_SmithA_Smith
You'll need to go back into the app, edit the lookup field definition and add a relationship name (the field is most likely blank right now).  That should give you a reference name for your code then.

Thanks,
Andrew
Roshan TamrakarRoshan Tamrakar
Awesome Smith,

Great! Thanks, it worked. Actually the field was not mandatory and I always skipped that. I never thought of that. You are the rescuer.

-Roshan
Ron WildRon Wild
I've run into a similar problem, but with a managed app.  And because it's managed, the name cannot be fixed after publishing. 

Salesforce uses a unique ID in lieu of a developer-assigned name.  So up until the last Salesforce update, I could just reference the child relationship by it's unique SF-assigned Id.

However, as of the last release,  AppExchange installation scripts add the application namespace prefix ( "myapp__" ) and the child relationship suffix ("__r") to the unique Id, making queries that work in the dev account break in the installed account.

To make matters worse, you can't just add the prefix and suffix strings in your dev account, because the prefix and suffix aren't used there.

I've been trying to get a fix from SF support for weeks now, with no success.  Has anyone else found a solution?




Bill EidsonBill Eidson
  The SOQL queries using just the R00NXXXXXXXXX form should be working now (both that form as well as the cron_R00NXXXXXXXXXXXX__r form should work).

  Thanks,

  - Bill

SuperfellSuperfell
When you create the lookup field, you can give the relationship a name, if you don't do that, you get a generated name.
Ron WildRon Wild
Thanks for the reply Bill ... I see that the error messages have gone away in my customers accounts (where I make the query call using the base relationship ID (sans prefix/suffix)) but I'm not getting any child record results when I know I should.

I'm making the SOQL call from inside the Flex toolkit.  Is it possible this is now a flex toolkit issue?




Message Edited by Ron Wild on 10-25-2008 08:33 PM
Bill EidsonBill Eidson
  Ron -

  I can't think of why you wouldn't be getting any results; let's troubleshoot this by phone.  I've sent you contact information.

  Thanks,

  - Bill