function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
montblanc2000montblanc2000 

s-control custom input page with lookup fields

Does anybody know how I can set 'lookup' fields through an s-control? I have an s-control that is a custom input page (overrides the 'edit' and 'new' buttons on a custom object) that creates a new object--a 'location'. I managed to get it to pass data for 'text' fields using [new object].set, but it fails when it comes to 'lookup' fields. I have tried passing both the name of the item as well as its id and neither worked. Any thoughts? Thanks in advance.

Paul
MyGodItsColdMyGodItsCold
I added a custom field to Account called Acct_Mail_Ownr_nm__c which is a lookup to User.

What I'm first trying to do is to display info from the lookup field. So, what I do is I run the query and include the field in the query and then, I reference it when I display Account information.

I think I have to reference the field as Acct_Mail_Ownr_nm__r.name. The __r structure comes along with a custom field when it is of Lookup type.

If you haven't downloaded Sforce Explorer, I strongly suggest you do it so you can 'inspect' your data structures and even run live queries against the data.

So, far, I'm struggling with getting the lookup data to display on the screen.

Now, what you're doing is trying to edit that data, right? I'm not sure how (if possible) to do that within S-Controls.

Visual Force, on the other hand, is an amazing tool. The downside is that we're just not sure when it's going to go into production. We're hoping for spring, but SF hasn't gotten to the point where they'll commit to that time table (to the best of my knowledge - I might be wrong).

As I get deeper into all of this, I'll update this thread.
montblanc2000montblanc2000
Thanks for responding. I actually figured out what I was doing wrong. In order to pass data to a lookup field in Salesforce, you have to use that object's ID. I had tried this before, but it wasn't working properly. As it turns out, Salesforce uses either 15- or 18-digit IDs to reference a record of any object it uses. When I was querying the Account ID from Accounts, I would get a 15-digit ID. If I did it form a child object of the Account (my custom object: "Location"), it would gave me an 18-digit ID that was the same 15-digit ID plus three more characters. You can only pass a 15-digit ID to a lookup field, so I had to truncate the last 3. I'm not sure why Salesforce behaves this way, but it has something to do with the parent-child relationship.

Thanks for the tip on Sforce Explorer--I haven't been able to get Eclipse to work properly so it's been quite a hassle for me using just the web interface.

What sort of problems are you having displaying the data?
MyGodItsColdMyGodItsCold

Well, when I run the query and try to reference the __r.name field, it gives me an error message. I opened up a ticket on it & will bring it up during a call in about 1/2 hr.

What kind of Eclipse issues are you having? Are you behind a firewall? That took us a while to solve. I did try to apply the latest upgrade of Apex plugin & it didn't work - but, I have most of what I need going in Eclipse right now. - We're even using Subversion for version control.