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
JakeHJakeH 

using asset.set on custom lookup id

Good morning all,

I’m working on customizing an S-Control that I grabbed from Salesforce called LineItems2Assets. This is a great s-control which allows items on an opportunity to automatically be converted into assets. Here’s the blog entry about it. It worked fine when I first got it and I’ve managed to customize it a little, but now I'm stumped.

I would like to store the opportunity that the asset came from. I made a custom field in the asset object called Opportunity_Source__c which is a lookup Id that should work just like the AccountId field in the asset object (which obviously stores the Account that the asset is tied to). I tried:

asset.set("Opportunity_Source__c","{!Opportunity.Id}");

It fails with The property Opportunity_Source__c is not a valid field.

In troubleshooting it, I changed it to

asset.set("Description","{!Opportunity.Id}");
It writes the id to the description field just fine.

Any idea where to turn? I’ve looked for an SDK that would include syntax for commands like asset.set, but haven’t found anything yet. Thanks in advance for any help! -Jake

CaptainObviousCaptainObvious
It looks like you are using the correct syntax for setting the value of a field.

Is the "Opportunity Source" field "Visible" for the profile in Field-Level Security and "Editable" in Field Accessibility? This could be why you are getting the "not a valid field" message.

On another note, the LineItems2Assets scontrol uses the beta ajax toolkit. You may want to migrate the control to the current version of the kit.

Check out the "Migrating from the Beta AJAX Toolkit" notes in the AJAX Toolkit Developer's guide: http://www.salesforce.com/us/developer/docs/ajax/apex_ajax.pdf
JakeHJakeH
Thanks for the reply!

The Opportunity Source is indeed visible and editable, but I had not checked those, so thanks for the idea. I'm a lousy developer, so I'm a bit scared of the migration notes, but I'm going to give it a shot.

On a separate note, I had to go check manually to see that there was a reply to this, even though I checked the "E-mail me if someone replies to this" - does anyone else have that problem?

-Jake