• dke01
  • NEWBIE
  • 290 Points
  • Member since 2009

  • Chatter
    Feed
  • 11
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 33
    Questions
  • 69
    Replies

I'm trying to give "apex managed sharing" a test run. I've created a custom object (in my sandbox) and I'm trying to run through how to handle creating share objects.

 

Right now, I'm getting a compile error that appears to be a syntactical error, but I can't figure it out.

 

In the documentation Here, the description of how to handle doing this is pretty clear: MyCustomObject__Share. In the example, referencing their Job__c object is done as "Job__Share".

 

My object is called RFQ. The api name is RFQ__c, so I would expect the share name to be RFQ__Share. I'm getting the error: "Invalid Type: RFQ__Share" when trying to compile my code. Here's a snippet:

 

 

/*
* Trigger to test Apex Managed Sharing
*/
trigger AssignSharing on RFQ__c (after insert) {
List<RFQ__Share> shares = new List<RFQ__Share>(); List<String> srNums = new List<String>(); Map<String, Id> userIds = new Map<String, Id>(); RFQ__Share shr = new RFQ__Share(); for(RFQ__c rfq : trigger.new) { //for each comma separated SR Num in the SR Num field, add it to //the list of relevant SR nums for(String num : rfq.Sales_Responsible_Numbers__c.split(',',0)) { srNums.add(num); } } //SR Nums now holds all the Sales Responsible numbers that apply to the //rfq's being inserted, so we can query them from the database; //next step is to iterate through all the users who will be assigned a
//sharing rule (query result)
//create a map of SR#s to Ids for quick reference later for(User u : [SELECT Id, Sales_Responsible_Number__c from User where Sales_Responsible_Number__c in :srNums]) { userIds.put(u.Sales_Responsible_Number__c, u.Id); } //userIds now maps each SR# to a user Id //for each new RFQ, assign the users that need to be given share priviledges
 for(RFQ__c rfq : trigger.new) { //for each sales responsible number for(String s :srNums) { //if this RFQ has that sales responsible number if(rfq.Sales_Responsible_Numbers__c.contains(s)) { //create a sharing rule that allows the corresponding user to be added shr.ParentId = rfq.Id; shr.AccessLevel = 'edit'; shr.UserOrGroupId = userIds.get(s); shr.RowCause = Schema.rfq__Share.RowCause.SalesResponsible__c; shr.add(shares); } }//end for loops over srNums for this rfq }//end for (trigger.new) insert shares; }//end trigger

 

(Don't make fun of my code... it's for testing, not even compiled once yet, and not made to be efficient, I just want to get it to compile)

 

 

Any insight?

Hi,

 

I've a qick question on governor limits: - Records retrived by SOQL is 10,000. My question is, is it for one Soql or for the whole organization which includes all Soql's??

 

I've an Soql retruning 5000 rows, another 7000 rows individually when i query in IDE, If i Include these 2 queries in diff classes then the total count might go upto 12,000 rows. Is this a problem or 2 Soql's count the rows individually as 5000 and 7000?

 

Thanks.

  • June 02, 2010
  • Like
  • 0

I am having problems with the governor limits on SOQL queries.  I am trying to populate a list.  I tried the "For" procedure as outlined in the Apex Documentation, but I couldn't get it to work.  I also tried to break the query into three parts and then add the parts to the list, and that didn't work either.  I am new to this, so any comments would be really appreciated.

 

 

trigger ClassList1 on Program_Schedule__c (after insert, after update) {

//create a variable to hold the records to insert into the Class Members Object

List<Class_Member__c> AddClassMembers = New List<Class_Member__c>();

//Get a list of approved clients for all programs

 

// using addall to list methodology

//List<Program_Interest__c> ApprovedClients = New List<Program_Interest__C>();
//ApprovedClients.addall ([Select Client__c, Already_Enrolled__c, Program_of_Interest__c from Program_Interest__c where Name < 'G' and Next_Session__c = true AND Already_Enrolled__c = False]);
//ApprovedClients.addall ([Select Client__c, Already_Enrolled__c, Program_of_Interest__c from Program_Interest__c where Name >= 'H' and Name < 'I' and Next_Session__c = true AND Already_Enrolled__c = False]);
//ApprovedClients.addall ([Select Client__c, Already_Enrolled__c, Program_of_Interest__c from Program_Interest__c where Name >= 'T' and Next_Session__c = true AND Already_Enrolled__c = False]);

 

//Using the For methodology
For(List<Program_Interest__c> ApprovedClients : [Select Client__c, Already_Enrolled__c, Program_of_Interest__c from Program_Interest__c where Next_Session__c = true AND Already_Enrolled__c = False])
{
//Get existing class lists for duplicate checking
List<Class_Member__c> ExistingClassMembers = New List<Class_Member__C>([Select Program_Schedule__C from Class_Member__C]);

//Get list size
Double TotalNumApprovedClients = ApprovedClients.Size();

//Create a trigger list to hold ids
List<id> ProgInstance = New List<id>();

//Iterate through trigger records
For (Program_Schedule__c PSACM : trigger.new){
//PSACM.Class_List_Created__C = True;
//PSACM.Create_Class_List__C = False;
ProgInstance.add(PSACM.id);
ProgInstance.add(PSACM.Program__c);
ID ProgSchedID = PSACM.ID;
ID ProgID = PSACM.Program__c;

//Check to see if create box is checked
If (PSACM.Create_Class_List__C == true){


//Double CountClients = [Select Count() from Program_Interest__c where Next_Session__c = true AND Id in :ProgInstance ];

//iterate through list of approved clients and add those with matching program id's to the AddClassMembers list
For (Program_Interest__c APPCL : ApprovedClients)
{
If (APPCL.Program_of_Interest__c == ProgID)
{
ID ClientID = APPCL.Client__c;
APPCL.Already_Enrolled__c = True;

AddClassMembers.add(New Class_Member__c(Client__c = ClientID, Program_Schedule__c = ProgSchedID, Program__c = ProgID ));

}
}

Double CountClientstobeadded = AddClassMembers.size();

//Check to see if the number of clients is greater than the class capacity
Double ClassCap = PSACM.Capacity__c;

If (ClassCap < CountClientstobeadded){
PSACM.AddError ('Too many clients for the class, adjust client numbers or increase class size');}

//check to see if class list exists
Double CountExistingClients = [Select Count() from Class_Member__c where Program_Schedule__C in :ProgInstance ];
Double ClassPlacesLeft = ClassCap - CountExistingClients;

If (CountClientstobeAdded  > ClassPlacesLeft){
PSACM.AddError ('Clients previously added, check and add manually if necessary');
}
//If (CountExistingClients == 0){


//If (ClassCap >= CountClientstobeadded){

//For (Program_Schedule__c PSACM : trigger.new)
//PSACM.Class_List_Created__C = True;
//PSACM.Create_Class_List__C = False;

try{
insert AddClassMembers;
Update ApprovedClients;
//Update PSACM;
}
catch (DmlException de) {
for (Integer i = 0; I < de.getNumDml(); i++) {
PSACM.addError(de.getDmlMessage(i));

}
}
}}
}}

HI all, i m new to this platform, also to Apex code development.

I m creating an application in which i need to use Apex programming,

i have java development background.

 

So what i need is, as many examples as possible in Apex programming,

so if anybody can provide me the websites which i can look into, so it will be helpful.

 

Thank You

Hey all,

I am in the process of shifting a bunch of tools into salesforce. To do this basically I am rewritting the front ends in jQuery (and plugins) and creating Apex web services that fetch the required data and return it in JSON format to the front end components.

 

I want to write one component, I can pass it a query string, it returns me a JSON formatted object. However, I am not handy enough in Apex syntax to pull this off. I have a framework in place, but I don't know 2 things.

 

1) How do I make a query completly out of a URL variable.

2) How can I loop over all the column names returned in a query?

 

Below is the code I have so far, that has been the basic outline of my componts so far, but I want to stop having to make a new component for every tool. Any help is appreciated. Thank you.

 

 

public class queryToJSON { public JsonObject json {get;set;} /** invoked on an Ajax request */ public void getJson() { //There should be a parameter called QueryString in the URL. Map<string,string> params = ApexPages.currentPage().getParameters(); json = new JsonObject(); // Do SOQL query to see if there are any records ! List<Events__c> records = new List<Events__c>(); // Here I need a totally dynamic query, built from the URL query string variable. // theoretically it would look like this. // records = [params.get('queryString')]; if (!records.isEmpty()) { // Jsonify the results ! List<JSONObject.value> values = new List<JSONObject.value>(); for (Events__c c : records) { JSONObject cjson = new JSONObject(); //Now for every column in the query, I need to construct a new JSON "element" //I can do that statically by typing something like this //cjson.putOpt('"id"', new JSONObject.value(c.Id)); //That adds the id field to my JSON object. But I won't know all the columns that are //being queried for, so I am going to need to loop over all the columns returned for every row //and add them dynamically to my JSON object. values.add(new JSONObject.value(cjson)); } json.putOpt('events', new JSONObject.value(values)); } } // Returns the JSON result string public String getResult() { string jsonString = json.ValuetoString(); return jsonString; } }

 

 

 

I want to upload a file using a pure HTML form, i.e. No Visual force but instead of gettign the file data as a Blob I just get a reference to the file as:

 

/home/sfdc/salesforce/sfdc/jsp/form/form1433903752.tmp   is there any API call we can use to convert that into an blob or attachment

 

This is my HTML

 

 <form id="myForm1" action="fileTest" method="POST" enctype="multipart/form-data">
       <input type="hidden" name="MAX_FILE_SIZE" value="100000" />

        File: <input type="file" name="file" />
   <input type="submit" value="Submit" />

  </form>

 

 

This my apex

 

 public fileTest()
    {
        Map<String, String> m = System.currentPageReference().getParameters();
        for(string key : m.keySet())
        {
              System.debug('============= key ='+ key  + ':'+     System.currentPageReference().getParameters().get(key));
            
        }
       
    }

 
I get back the file name, file content type, but not the file binary data just a internal folder/file path such as /home/sfdc/salesforce/sfdc/jsp/form/form1433903752.tmp    is there any hooks I can use to covert that into a Blob?

 

Yes I do know I can use Visualforce to do this and save directly to an Attachment or Document. But I do not want to do this.

 

  • July 30, 2010
  • Like
  • 0

Using the default sObject page layout editor is there anyway to change  a Relationship field to be displayed as a  select box instead of a Lookup field with the search icon that opens a popup,

 

  • June 30, 2010
  • Like
  • 0

I want to get a list of classes at run time.  Such as spring would allow in java.  lIke a facorty.

 

Is there anyway to achive a similar result in APEX.

 

For example I want to get a list of all classes that implement a interface.  I have also named my classes consitantly so I can query for them

 

i.e.

 

Select Name from ApexClass where Status = 'Active' AND Name like 'My_XML%'

 

This returns 20 classes.  I want to create a new instance of each class and call a method on it.  Is this achiveable?

  • June 21, 2010
  • Like
  • 0

Why doesn't this code work

 

 

 DOM.Document doc = new DOM.Document();
 DOM.XmlNode treeNode =  doc.createRootElement('RootNode', null ,null);
 treeNode.addChildElement('testNode', null, null).addTextNode('hello world');
 System.debug( '===========' + treeNode.getText() );

 

I would expect it to print out

<RootNode>
   <testNode>hello world</testNode>
</RootNode>

 

But Instead I get nothing just a blank string.

 

Calling 

 System.debug('==============='+doc.toXmlString());
Works  But I do NOT want to do this, I want to get the XMLNode text only!!!!

 

  • June 18, 2010
  • Like
  • 0

How does attachments and sharing work?

 

I thought that it would be setup as a mater-detail to the parent and the attachment sharing would be based off of the parents sharing rules?

 

I have a parent Object

 

Foo_c

 

User A is the Owner.   And I have given User B Read Write permission to a row.  This row has an attachment.

 

User A can view, edit the attachment find as he is the owner.

 

However

User B can access the attachment directly by going to the URL  /servlet/servlet.FileDownload?file= <ATTACHMENTID>

this works.

 

But doing a SOQL select stament for all attachments where parentID = xxx     Does not work for user B.

 

How can I fix this so User B can have the same sharing rules as user A.

 

There doesn not seem to be an Attachment__share object.   But there is a Foo__share Object  but these setting do not seem to carry across for attachments.

  • May 28, 2010
  • Like
  • 0

I have a Site setup with users with a 'Gold Partner' license however I cannot seem to add/upload documents with these users.

 

Looking at  'Profile Edit' page for 'Gold Partner' under standard object  Documents only has a 1 checkbox available Read  there is no option for Write / Delete.

 

I thought according to http://blog.jeffdouglas.com/2009/08/25/salesforce-com-licenses/ (yes i know this is not an offical salesforce page) that Gold users could use documents.

 

If not how can I upload a file as a Gold user  by using the RunAs command? Is that my only option. Or is there some other setting I am missing somewhere

  • May 25, 2010
  • Like
  • 0

I am using a reqular HTML input textbox.  (I do not want to use an apex:inputfield)

 

My code is like this:  <input type="text"value="{!object.field}" />

 

However if field has a double quote in it  instead of generating       <input type="text"value="somevalue " foo" />

 

It generates  <input type="text"value="somevalue" foo="" />    in Firefox

 

Howcan I escape/replace  "  so that the HTML element is rendered with the correct value.

 

  • May 20, 2010
  • Like
  • 0

I have a page like this

 

<apex:page controller="My_Controller">
<apex:form >
<apex:inputField value="{!foo.bar__c }"/>
  <apex:commandButton value="Search" action="{!search} />
</apex:form > </apex:page>

 

 

And my controller

 

public class My_Controller
{
    public Foo__c foo {get; set;}

    public My_Controller()
    {
        foo = new foo__c();
    }

public PageReference search()
{
return null;
}

}

 

I cannot seem to make a lookup field work on the page.  THe page displays ok, the look up field works.  But when I press the command button I get the error

 An error occurred when processing your submitted information

 

 

  • May 10, 2010
  • Like
  • 0

How do I view the log of field changes when using Track Field History.

 

I have turned on Track Field History on my Custom Object.  I have selected what columns/fields I woud like to track.

 

I looked at this thread http://community.salesforce.com/t5/Visualforce-Development/How-to-Find-History-Tracking-or-Audit-Log/td-p/132600  on  how to add a related list to a page layout to view the history..  However when I go to edit my page layout there is not related list of field history?

 

Is the only way I can view field history by creating a report? I was really hoping this information would be available from the built in page layout that VF provides.  Or is this just a bug in Spring 10  that History tracking is not showing in the page layout.

  • April 29, 2010
  • Like
  • 0

How can I select using Dynamic SOQL rows over 2 master details relationships.

 

Here is my structure

 

Foo --< FooRole  >--  Role__c --< RoleUser >-- User__c

I want to select all Foos that have a Role that the User is in.

 

My first attempt was:

 

SELECT id FROM Foo WHERE Id in 
(SELECT Foo__c FROM FooRole WHERE Role__c in 
  (SELECT Role__c FROM RoleUser__c WHERE User__c = '005S0000000G8KqIAK' ) 
) 

 

 

But I got an error "unexpected right parenthsis found,  I assume that SOQL does not like nested IN statements

So next I tried to do 2 seperate SOQL statements like

 

List<fooRole> temp = [SELECT id FROM FooRole WHERE Role__c in 
  (SELECT Role__c FROM RoleUser__c WHERE User__c = '005S0000000G8KqIAK' ) 

 

Then Say

 

SELECT id FROM Foo WHERE FooRole__r in (temp)

 

But this does not work either?  How can I do this?

The only other solution I could get working  is looping through the Temp array getting the Foo__c ID out of it and and concatenating a string like (id1,id2,id3)

 

 

SELECT id FROM Foo WHERE id in (myListOfFooIDs)

 

But I do not want to do this as myListOfFooIDs could be come quite long.

 

 

 

  • April 27, 2010
  • Like
  • 0

Is there an event in a Controller that is fired after the setters and getters have been called.

 

I want to setup some data once the setters and getters have finished so I cannot use the constructor

 

is there like a   page_load, awake,  or sleep  event that other major Web Application frameworks support?

 

 

  • April 23, 2010
  • Like
  • 0

What is the best way to check if a custom setting exist?

 

I get my custom setting dynamically like so

 

 

MySetting__c setting = MySetting__c.getInstance('default');
return setting.get(settingName);

 

 

But if I pass setting name a field that does not exist - Then I get the following exception:

"System.SObjectException: Invalid field 'xxx' for MySetting__c"

 

And Silly APEX does not allow me to Try Catch this exception and handel it myself FFS.

 

So how can I check if a field exist on an Object.  Is the only way using a Describe call?

  • April 14, 2010
  • Like
  • 0

Is there a way I can so a String.replace('old', 'new')   with in VF?  Not using a controller

 

Does a output panel allow this?

 

What I am trying to do is replace/escape  newlines chars

  • April 09, 2010
  • Like
  • 0

Hi,

 

I want to return value of a custom setting as a string.

 

For example

 

MyCustomSettingInstance.getValueForField('foo');

 

Is this achievable?

 

Or can I do via dynamic SOQL somehow?

 

Like

query = 'SELECT '+ foo +' from MySetting__C where .......'

Then return just the String value for foo and not an sObject?

  • April 06, 2010
  • Like
  • 0

How can I determine if  the current page is running in HTTP or HTTPS mode

it seems: ApexPages.currentPage().getHeaders();  does not contain this information

  • March 31, 2010
  • Like
  • 0

Does anyone have any examples of how to call the Amazon S3 Rest API http://docs.amazonwebservices.com/AmazonS3/latest/RESTObjectOps.html

 

I know how to use the AWS SOAP examples but not all of the S3 API is available via SOAP so I would prefer to use REST.  Any pointers.  As all my code currently returns  status code 403 Forbidin 

  • March 24, 2010
  • Like
  • 0

I want to make a reusable component I can use to upload files.

 

I want to set the attachment.ParentID but do not know that as the file may be uploaded before the object is inserted.  

 

I thought I would be able to add the attachment to a Temporary object.  wait for the newly inserted object to get an ID  when set the ParentID  and then call an Update.

 

 

But I get the error  Field is not writeable: Attachment.ParentId  anyway around this,. Why does force.com allow ParentID to change?

 

Is there a way I can getNextID()   so before I insert an object I know what its ID will be?

Message Edited by dke01 on 22-03-2010 03:48 PM
  • March 22, 2010
  • Like
  • 0

When I create a component and give attribute descriptions I can access the Component Reference the HTML guide of all the components their arguments.

 

I notice that for the builtin components they have a Over all description at the top of the page and a usage tab.

 

Is there anyway I can create either of these for my custom componets. 

 

I thought what I would write in the Description textarea on the edit component screen would appear in this reference but I guess the SF people didn't think that straigh foward.

Message Edited by dke01 on 18-03-2010 02:13 PM
  • March 18, 2010
  • Like
  • 0

How do I do this:

 

Integer totalRows = (Database.query(myQuery ))

 

 Now I get a error cannot convert sObject to Integer

 

  • March 15, 2010
  • Like
  • 0

I am trying to insert a custom setting for a user as such

 

MySetting__c x = new MySetting__c(); x.name = 'blfd'; x.setupOwnerId = UserInfo.getUserId(); insert(x);

 

 The error I get is "System.DmlException: Insert failed. First exception on row 0; first error: FIELD_INTEGRITY_EXCEPTION, field integrity exception: SetupOwnerId (id value of incorrect type): [SetupOwnerId]"

 

  • March 08, 2010
  • Like
  • 0

I want to get a list of classes at run time.  Such as spring would allow in java.  lIke a facorty.

 

Is there anyway to achive a similar result in APEX.

 

For example I want to get a list of all classes that implement a interface.  I have also named my classes consitantly so I can query for them

 

i.e.

 

Select Name from ApexClass where Status = 'Active' AND Name like 'My_XML%'

 

This returns 20 classes.  I want to create a new instance of each class and call a method on it.  Is this achiveable?

  • June 21, 2010
  • Like
  • 0

I made some updates to the APEX Explorer to fix some problems:

 

  1. Changed the SOQL editer to use ScintillaNet(scintillanet.codeplex.com)
  2. Added support for single line(--) and multiline comments(/* */) in SOQL statments. (they get striped out before the api call)
  3. Fixes so it works with version 19 of SalesForce API
  4. Fixed the GridView, you can now do "Show in Browser" and "Copy ID" with our crashing
  5. Fixed "Start DB Replication Monitor" from crashing the app

 

The updated source is in the download.

 

DOWNLOAD:
http://www.grimeware.com/ApexExplorer8.1.zip

This is the scenario. when a check box is check. it will appear on the page.. but when its null it will not be displayed.

I'm trying to give "apex managed sharing" a test run. I've created a custom object (in my sandbox) and I'm trying to run through how to handle creating share objects.

 

Right now, I'm getting a compile error that appears to be a syntactical error, but I can't figure it out.

 

In the documentation Here, the description of how to handle doing this is pretty clear: MyCustomObject__Share. In the example, referencing their Job__c object is done as "Job__Share".

 

My object is called RFQ. The api name is RFQ__c, so I would expect the share name to be RFQ__Share. I'm getting the error: "Invalid Type: RFQ__Share" when trying to compile my code. Here's a snippet:

 

 

/*
* Trigger to test Apex Managed Sharing
*/
trigger AssignSharing on RFQ__c (after insert) {
List<RFQ__Share> shares = new List<RFQ__Share>(); List<String> srNums = new List<String>(); Map<String, Id> userIds = new Map<String, Id>(); RFQ__Share shr = new RFQ__Share(); for(RFQ__c rfq : trigger.new) { //for each comma separated SR Num in the SR Num field, add it to //the list of relevant SR nums for(String num : rfq.Sales_Responsible_Numbers__c.split(',',0)) { srNums.add(num); } } //SR Nums now holds all the Sales Responsible numbers that apply to the //rfq's being inserted, so we can query them from the database; //next step is to iterate through all the users who will be assigned a
//sharing rule (query result)
//create a map of SR#s to Ids for quick reference later for(User u : [SELECT Id, Sales_Responsible_Number__c from User where Sales_Responsible_Number__c in :srNums]) { userIds.put(u.Sales_Responsible_Number__c, u.Id); } //userIds now maps each SR# to a user Id //for each new RFQ, assign the users that need to be given share priviledges
 for(RFQ__c rfq : trigger.new) { //for each sales responsible number for(String s :srNums) { //if this RFQ has that sales responsible number if(rfq.Sales_Responsible_Numbers__c.contains(s)) { //create a sharing rule that allows the corresponding user to be added shr.ParentId = rfq.Id; shr.AccessLevel = 'edit'; shr.UserOrGroupId = userIds.get(s); shr.RowCause = Schema.rfq__Share.RowCause.SalesResponsible__c; shr.add(shares); } }//end for loops over srNums for this rfq }//end for (trigger.new) insert shares; }//end trigger

 

(Don't make fun of my code... it's for testing, not even compiled once yet, and not made to be efficient, I just want to get it to compile)

 

 

Any insight?

Hi,

 

I've a qick question on governor limits: - Records retrived by SOQL is 10,000. My question is, is it for one Soql or for the whole organization which includes all Soql's??

 

I've an Soql retruning 5000 rows, another 7000 rows individually when i query in IDE, If i Include these 2 queries in diff classes then the total count might go upto 12,000 rows. Is this a problem or 2 Soql's count the rows individually as 5000 and 7000?

 

Thanks.

  • June 02, 2010
  • Like
  • 0

I am having problems with the governor limits on SOQL queries.  I am trying to populate a list.  I tried the "For" procedure as outlined in the Apex Documentation, but I couldn't get it to work.  I also tried to break the query into three parts and then add the parts to the list, and that didn't work either.  I am new to this, so any comments would be really appreciated.

 

 

trigger ClassList1 on Program_Schedule__c (after insert, after update) {

//create a variable to hold the records to insert into the Class Members Object

List<Class_Member__c> AddClassMembers = New List<Class_Member__c>();

//Get a list of approved clients for all programs

 

// using addall to list methodology

//List<Program_Interest__c> ApprovedClients = New List<Program_Interest__C>();
//ApprovedClients.addall ([Select Client__c, Already_Enrolled__c, Program_of_Interest__c from Program_Interest__c where Name < 'G' and Next_Session__c = true AND Already_Enrolled__c = False]);
//ApprovedClients.addall ([Select Client__c, Already_Enrolled__c, Program_of_Interest__c from Program_Interest__c where Name >= 'H' and Name < 'I' and Next_Session__c = true AND Already_Enrolled__c = False]);
//ApprovedClients.addall ([Select Client__c, Already_Enrolled__c, Program_of_Interest__c from Program_Interest__c where Name >= 'T' and Next_Session__c = true AND Already_Enrolled__c = False]);

 

//Using the For methodology
For(List<Program_Interest__c> ApprovedClients : [Select Client__c, Already_Enrolled__c, Program_of_Interest__c from Program_Interest__c where Next_Session__c = true AND Already_Enrolled__c = False])
{
//Get existing class lists for duplicate checking
List<Class_Member__c> ExistingClassMembers = New List<Class_Member__C>([Select Program_Schedule__C from Class_Member__C]);

//Get list size
Double TotalNumApprovedClients = ApprovedClients.Size();

//Create a trigger list to hold ids
List<id> ProgInstance = New List<id>();

//Iterate through trigger records
For (Program_Schedule__c PSACM : trigger.new){
//PSACM.Class_List_Created__C = True;
//PSACM.Create_Class_List__C = False;
ProgInstance.add(PSACM.id);
ProgInstance.add(PSACM.Program__c);
ID ProgSchedID = PSACM.ID;
ID ProgID = PSACM.Program__c;

//Check to see if create box is checked
If (PSACM.Create_Class_List__C == true){


//Double CountClients = [Select Count() from Program_Interest__c where Next_Session__c = true AND Id in :ProgInstance ];

//iterate through list of approved clients and add those with matching program id's to the AddClassMembers list
For (Program_Interest__c APPCL : ApprovedClients)
{
If (APPCL.Program_of_Interest__c == ProgID)
{
ID ClientID = APPCL.Client__c;
APPCL.Already_Enrolled__c = True;

AddClassMembers.add(New Class_Member__c(Client__c = ClientID, Program_Schedule__c = ProgSchedID, Program__c = ProgID ));

}
}

Double CountClientstobeadded = AddClassMembers.size();

//Check to see if the number of clients is greater than the class capacity
Double ClassCap = PSACM.Capacity__c;

If (ClassCap < CountClientstobeadded){
PSACM.AddError ('Too many clients for the class, adjust client numbers or increase class size');}

//check to see if class list exists
Double CountExistingClients = [Select Count() from Class_Member__c where Program_Schedule__C in :ProgInstance ];
Double ClassPlacesLeft = ClassCap - CountExistingClients;

If (CountClientstobeAdded  > ClassPlacesLeft){
PSACM.AddError ('Clients previously added, check and add manually if necessary');
}
//If (CountExistingClients == 0){


//If (ClassCap >= CountClientstobeadded){

//For (Program_Schedule__c PSACM : trigger.new)
//PSACM.Class_List_Created__C = True;
//PSACM.Create_Class_List__C = False;

try{
insert AddClassMembers;
Update ApprovedClients;
//Update PSACM;
}
catch (DmlException de) {
for (Integer i = 0; I < de.getNumDml(); i++) {
PSACM.addError(de.getDmlMessage(i));

}
}
}}
}}

I have a couple of issues;

1. SFDC claims that setClientCertificate is deprecated, and to use setClientCertificateName instead, so where exactly am I supposed to upload or install the Server Certificate generated for my secure server?  I was surprised that I could not upload a cert of a CA when I added my secure servers URL to the remote sites section.  Furthermore following the "please use setClientCertificateName" links it points me to a section that shows me how to generate certs on SFDC.

 Thats not going to happen for the following reasons;

a. I don't require two way ssl

b. I am making callouts.

 

 

2. For development, we do our own signing.  i.e. I am my own CA and I generate a bunch of server certs signed by this CA.  So how do I get SFDC to trust my dev CA.  I am hardly going to go to verisign to get certs signed for development servers on my end, nor am I going to allow anyone to call into my servers without SSL.  

 

 

So in short;

I need SFDC APEX calls to behave like a browser would, where RESTful calls to HTTPS just work, if you install the CA that signed those certs.  It should be as simple as that, and I can't believe I am the only one that has run into this issue.

 

Anyone have some guidance

 

Thanks

 

 

 

I have a trigger that loops thru all Opportunity Products and updates the related opportunity.  The trigger works fine if there isn't more than 3 or 4 Opportunity Products, but it bombs if there are more than 5 Opportunity Products.  I'm trying to make my trigger bulk safe.  Can someone provide some help on how to refactor my trigger to make it bulk safe?

 

trigger OpportunityUpdateFromOppProduct on OpportunityLineItem (after insert, after update) {
	
	List<OpportunityLineItem> olis = [Select Id, OpportunityId, Service_Code__c, Is_Full_Service__c From OpportunityLineItem Where OpportunityId =: Trigger.new[0].OpportunityId];
	
	for (OpportunityLineItem oli : olis) {
		
		Service_Code__c sc = [Select Opportunity_Service_Field_Name__c From Service_Code__c Where Name =: oli.Service_Code__c];

		String soql = 'Select ' + sc.Opportunity_Service_Field_Name__c + ' From Opportunity Where Id = \'' + oli.OpportunityId + '\'';

		List<Opportunity> opps = Database.query(soql);
		
		string serviceFieldValue;
		
		if (oli.Is_Full_Service__c == 'True') {
			serviceFieldValue = 'Full';
		}
		else {
			serviceFieldValue = 'Partial';
		}
		
		if (opps[0].get(sc.Opportunity_Service_Field_Name__c) != 'Full') {
			opps[0].put(sc.Opportunity_Service_Field_Name__c, serviceFieldValue);
		}
		update opps;
	}
}

 

Thanks.

How does attachments and sharing work?

 

I thought that it would be setup as a mater-detail to the parent and the attachment sharing would be based off of the parents sharing rules?

 

I have a parent Object

 

Foo_c

 

User A is the Owner.   And I have given User B Read Write permission to a row.  This row has an attachment.

 

User A can view, edit the attachment find as he is the owner.

 

However

User B can access the attachment directly by going to the URL  /servlet/servlet.FileDownload?file= <ATTACHMENTID>

this works.

 

But doing a SOQL select stament for all attachments where parentID = xxx     Does not work for user B.

 

How can I fix this so User B can have the same sharing rules as user A.

 

There doesn not seem to be an Attachment__share object.   But there is a Foo__share Object  but these setting do not seem to carry across for attachments.

  • May 28, 2010
  • Like
  • 0

Hi all, I developed an .net Application wich uses EnterpriseWSDL API from sealesforce. Currently this application USes my username and password and connects to salesforce to get the dat from sales force. Now my Doubt is when i open my website i have login page where in other users login with there Username and password in to the website.How do i make salesforcesession available to them as well.

 

I mean to say once the  webapplication is deployed  all the users who authorized members of my website should be able to acess the salesforce Object records as soon as they login with their web user ID and passsword. all the users who have aces to the site are also  users of my salesforce application..

 

Hope this makes sense.

 

Thanks in advance.

Giribabu

I am using a reqular HTML input textbox.  (I do not want to use an apex:inputfield)

 

My code is like this:  <input type="text"value="{!object.field}" />

 

However if field has a double quote in it  instead of generating       <input type="text"value="somevalue " foo" />

 

It generates  <input type="text"value="somevalue" foo="" />    in Firefox

 

Howcan I escape/replace  "  so that the HTML element is rendered with the correct value.

 

  • May 20, 2010
  • Like
  • 0

i have been trying to get datepicker to work with my visualforce page. I set it up but i can not get the calendar to pop up. 

Here is my code:

 

 

<apex:page controller="testController">
<link type="text/css" href="{!URLFOR($Resource.css)}" rel="stylesheet" />
<script type="text/javascript" src="{!URLFOR($Resource.Jquery)}"></script>
<script type="text/javascript" src="{!URLFOR($Resource.core)}"></script>
<script type="text/javascript" src="{!URLFOR($Resource.Datepicker)}"></script>
 
<input id="datepicker" type="textbox" />
<script type="text/javascript">
    $(function() {
        $(“#datepicker”).datepicker();
    });
    </script>
 
<apex:form >
 <apex:inputText value="{!inputValue}" id="datepicker"/><br/>
 <apex:commandButton action="{!testAction}" value="testButton"/>
 </apex:form>
</apex:page>

 

 

Thanks for any help you can give.

I have a page like this

 

<apex:page controller="My_Controller">
<apex:form >
<apex:inputField value="{!foo.bar__c }"/>
  <apex:commandButton value="Search" action="{!search} />
</apex:form > </apex:page>

 

 

And my controller

 

public class My_Controller
{
    public Foo__c foo {get; set;}

    public My_Controller()
    {
        foo = new foo__c();
    }

public PageReference search()
{
return null;
}

}

 

I cannot seem to make a lookup field work on the page.  THe page displays ok, the look up field works.  But when I press the command button I get the error

 An error occurred when processing your submitted information

 

 

  • May 10, 2010
  • Like
  • 0

Is anyone doing this successfully?  We're at a point where I'd like to migrate from just using regular code comments to using full blown javadoc-accessible documentation, to make it easier and more appealing for our devs to reuse code.

 

Can anyone provide any examples of generating javadoc html from the .cls files stored by Eclipse?

Good day,

 

Can i know if Apex:Repeat tag's value able hold Map instead of List ?

 

 

VF page
------------
<apex:repeat value="{!partnerFieldList}" var="field">

<apex:variable var="currentLabel" value="{!$Label.first_name}" rendered="{field.containsKey('First_Name__c')}"/>


Controller
-----------
public Map<String,Boolean> partnerFieldList = new Map<String,Boolean>{
'First_Name__c' => TRUE

};

 

public Map<String,Boolean> getPartnerFieldList(){
return partnerFieldList;

 

 

 I would like to rendered the 'firstname' variable if the field are calling, but i get "Unsupported type common.apex.runtime.impl.MapValue encountered."error when i run the apex page

 

Thank you !

 

  • November 10, 2009
  • Like
  • 1

Hi Friends,

 

I have requirement like i need to repeat a list to show the label of the field in front end

While user select the field and save the data, only the api name of the field should get stored in DB.

 

Controller:

----------- 

List<String> fieldList = new List<String>(); 

 Map<String, Schema.SObjectField> fMap = Schema.SObjectType.Account.fields.getMap();
         List<Schema.SObjectField> fTokens = fMap.values() ;

            for( Integer i = 0 ; i < fTokens.size() ; i++ )
               {
                     Schema.DescribeFieldResult f = fTokens.get(i).getDescribe();
                     if( f.isAccessible())  { 
                      fieldList.add(f.getLabel());  
                     fieldList.add(f.getName()); 

              }

 

 

 

VF Page:

----------

 

 <apex:repeat value="{!matrix}" var="r" id="segId2">
            <td width="10%">
                 <apex:repeat value="{!r}" var="c" id="fldd">
                    <apex:inputCheckbox id="chk"  value="{!c}" onclick="return getValues(this,'{!$Component.fieldVal}','{!$Component.MarSeg}','{!$Component.hidd}');"/> <apex:outputLabel value="{!c}" id="fieldVal">
                    </apex:outputLabel>
                    <br />
                 </apex:repeat>

Here I need to use lable to display in the front end and while click save button i need to save button of the specific field into the DB.

 

Kindly suggest me a solution for this.

Any help is appreciated.

 

Thanks,

Ghilli.

  • October 23, 2009
  • Like
  • 0

Hi All

 

I am developing a VisualForce page and I need to pass a parameter to controller class. Why do I need to pass a parameter?, because I try to paint a table in HTML using a repeat apex component <apex:repeat>. The method called returns to VisualForce page a values map and I need to pass a key map to controller class.

 

Controller

 

public class claControlFormatoCotizacionSolicitud{ transient Map<String, Map<String, Double>> totalesAnticipos = new Map<String, Map<String, Double>>(); transient List<String> monedasAnticipos = new List<String>(); String tipoAnticipo {get;set;} public void calcularAnticiposSolicitud() { Map<String, String> monedasConsulta = new Map<String, String>(); List<Anticipo__c> consultaAnticipos = [SELECT Moneda__c, Tipo__c, Valor__c FROM Anticipo__c WHERE Solicitudes_de_viaje__c = :ApexPages.currentPage().getParameters().get('identificadorSolicitud') AND Tipo__c <> 'Tiquetes' AND IsDeleted = false ORDER BY Tipo__c ASC LIMIT 1000]; for(Anticipo__c registroAnticipo :consultaAnticipos) { monedasConsulta.put(registroAnticipo.Moneda__c, registroAnticipo.Moneda__c); } for(String monedaRegistro :monedasConsulta.values()) { monedasAnticipos.add(monedaRegistro); } monedasAnticipos.sort(); for(Anticipo__c registroAnticipo :consultaAnticipos) { if (totalesAnticipos.containsKey(registroAnticipo.Tipo__c)) { Map<String, Double> totalesTipo = totalesAnticipos.get(registroAnticipo.Tipo__c); if (totalesTipo.containsKey(registroAnticipo.Moneda__c)) { Double valorTotal = totalesTipo.get(registroAnticipo.Moneda__c); valorTotal = valorTotal + registroAnticipo.Valor__c; totalesTipo.put(registroAnticipo.Moneda__c, valorTotal); totalesAnticipos.put(registroAnticipo.Tipo__c, totalesTipo); } } else { Map<String, Double> totalesTipo = new Map<String, Double>(); for(String monedaTipo :monedasAnticipos) { if (monedaTipo == registroAnticipo.Moneda__c) { totalesTipo.put(registroAnticipo.Moneda__c, registroAnticipo.Valor__c); } else { totalesTipo.put(monedaTipo, 0); } totalesAnticipos.put(registroAnticipo.Tipo__c, totalesTipo); } } } } public List<String> getMonedasAnticipos() { return monedasAnticipos; } public List<String> getTiposAnticipos() { List<String> tiposAnticipos = new List<String>(); for(String tipoRegistro :totalesAnticipos.keySet()) { tiposAnticipos.add(tipoRegistro); } return tiposAnticipos; } public List<Double> getTotalesMonedas() { String tipoRegistro = System.currentPageReference().getParameters().get('tipoAnticipo'); List<Double> totalesTipo = totalesAnticipos.get(tipoRegistro).values(); return totalesTipo; } }

 

 VisualForce Page

 

<apex:page action="{!calcularAnticiposSolicitud}" controller="claControlFormatoCotizacionSolicitud" renderAs="pdf" showHeader="false" title="FTUG01 - Formato Solicitud Cotización de Tiquetes y Hotel"> <apex:form id="forCotizacionSolicitid"> <table border="1" width="100%"> <tr> <td></td> <apex:repeat value="{!MonedasAnticipos}" var="detalleMoneda"> <td><apex:outputText value="{!detalleMoneda}"/></td> </apex:repeat> </tr> <apex:repeat value="{!TiposAnticipos}" var="detalleTipo"> <tr> <td> <apex:outputText value="{!detalleTipo}"> <apex:param assignTo="{!tipoAnticipo}" name="tipoAnticipo" value="{!detalleTipo}"/> </apex:outputText> </td> <apex:repeat value="{!TotalesMonedas}" var="detalleTotal"> <td><apex:outputText value="{!detalleTotal}"/></td> </apex:repeat> </tr> </apex:repeat> </table> </apex:form></apex:page>

 

But when I execute the VisualForce page, the parameter "tipoAnticipo" is empty or null. 

 

 

 

Hi,

 

I'm posting into a VisualForce Page a form which contains binary data. I am looking through the parameters returned and have seen these values:

RemoteFile:/home/sfdc/salesforce/sfdc/jsp/form/form1981773126.tmp RemoteFile.content-type:application/octet-stream RemoteFile.file:/home/sfdc/salesforce/sfdc/jsp/form/form1981773126.tmp RemoteFile.filename:7463.jpg

Does anybody know what the entries for RemoteFile and RemoteFile.file mean? (filename is the name of the file I posted.)

Has anybody tried to access these values before? I have tried to use the URL by copying and pasting into my browser but get the url no longer exists message.

 

Is there a way to directly access the request object then posted the data to the page?

 

Thanks for any help.

R.