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
bakumbakum 

2 Noob questions

Hi, I'm a PHP developer tasked with creating an app for Salesforce.  I've got my work cut out for me. 

First off, I'm going through the language reference and the quick start in particular but there's a problem.  Page 15 hsa instructions for creating my first Apex code program, but it causes an error: "Error: Compile Error: expecting "package", found 'global' at line 1 column 1"

Any help here?

Secondly, I am on my own trying to cobble together an application and it's going OK.  I have a field which is a lookup-relationship with the User object.  I want the choices in that field to be restricted to a subset of users, and I am just not sure where to begin to do this sort of thing.  I'd also like to have a multi-select field related to the User object, in the same way (i.e. a subset of the user object).

If someone can point me in the write direction (like, oh, just write an s-control or put a trigger on it or whatever) I will go through the docs until I figure it out.  I'm just not sure where to start!

thanks,
MB
A.V.A.V.
I am not an authority on Apex, but here are a few things that may point you to the right direction:

1. Not sure page 15 of which document you are referring to, but the basic syntax is that every Apex package should be defined as

package <name> {

//variables amd methods here

}

Note that with Summer 07 release, the syntax changes and 'package' is being replaced with 'class'. So depending on your which release your org is at the moment, you may need to use different syntax.

2. I do not think that you can modify the standard behavior of the user lookup dialog, therefore as you said you may have to create an S-Control that would do the filtering and present a custom dialog page.

If your user-filtering logic is going to be reused you may even separate it into an Apex Code package, expose it as a webMethod and call this method from inside your S-Control to retrieve the list of users. I haven't tried this approach before, but if you do, let me know how this works.

Also, before you go into developing all this logic, is it possible to limit the users list by using standard Sfdc visibility settings? This depends on your use case, but just something to consider.


Cheers,
Andrey