• okaylah52
  • NEWBIE
  • 30 Points
  • Member since 2008

  • Chatter
    Feed
  • 1
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 17
    Questions
  • 34
    Replies
   
In a testMethod, I have following code:

Account_Auditor__c Account_auditor = new Account_Auditor__c(Account__c = a.id, auditor__c = u.id, Audit_Type__c = 'Garbage');
insert Account_auditor;
The intent is to execute the following trigger and give the "Auditor" read rights to the Account .

The testMethod runs fine in developer org, it croaks in the org that it is being installed it - it croaks on the Insert statement with the message:

caused by: System.DmlException: Insert failed. First exception on row 0; first error: INSUFFICIENT_ACCESS_ON_CROSS_REFERENCE_ENTITY, insufficient access rights on cross-reference id

trigger grantAuditorReadAccessToAccount on Account_Auditor__c (after insert) {

Account_Auditor__c[]  Account_auditor_list = trigger.new;

for (Account_Auditor__c Account_auditor: Account_auditor_list) {
AccountShare ashare = new AccountShare();
ashare.AccountAccessLevel = 'Read';
ashare.OpportunityAccessLevel = 'None';
ashare.CaseAccessLevel = 'None';
ashare.AccountId = Account_auditor.Account__c;
ashare.UserorGroupId = Account_auditor.Auditor__c;
Insert ashare;
}
}

I suspect it has something to do with the user rights - I am fetching an active user from the database in the test method (u.id). In the org that I am installing, I have two users, one is system admin, another is a test user I created, so that i could install. I assume I am installing as a


Is there a built-in generic function to find a list of changes/differences between two objects of same type, e.g. opportunity?

 

For example: in updating an opportunity, in my trigger, i want to detect get a list of which fields have been changed. I wrote a function to detect any change by comparing all fields in an opportunity old against new.

 

Thanks.

Please pardon this newbie question and provide the link if this has been answered before

 

I develop an Apex class X. I write another Apex class Y as a test class of X. When I migrate X to production, do I have to migrate Y too?

 

Thanks.

We installed a package we developed. But now we want to remove the package but we still want to keep all components, e.g. Apex classes, triggers, custome fields, etc in tact. Can we just remove everything from the package using the Remove option in the Package Detail/Package Components section?

 

Thanks.

Is there any documentation or general process that has been published regarding how to manage project files, code repository CVS, and Eclipse IDE?

 

We have a dev sandbox and a training sandbox. The training sandbox is supposed to be closest to the production environment in term of configuration settings. Codes are migrated from dev to training sandbox for final testing. After passing final testing, final codes are migrated from the training sandbox to the production server. From time to time, the training sandbox will be out of synch with the production (changes done directly on the production may not be propagated/re-done in the training sandbox).

 

In this kind of situation, what is your view/strategy on managing the source code repository using Eclipse IDE?

 

Thanks.

 

 

I have a list of SObjects. I pass the list to a utility method to check. In the method, it calls addError() of an SObject. How can I retrieve or go through the list and check which item has an error?

 

Thanks.

How can I override a delete link/command in a related list? Or is there a trigger related to CampaignMember table?

I am interested in particular overriding the delete link/command of the Campaign Member Extras related list in the Campaign detail page or of the Campaign History related list in the Contact detail page.

(I want to detect if a CampaignMember is created or deleted, then I update Account object accordingly)

Thanks.

(Crossed out incorrect info. Campaign Member Extras is my custom object in my attempt to have extra campaign fields since we can't have custom fields in CampaignMember)


Message Edited by okaylah52 on 01-08-2009 05:23 PM
Hi All,

I apologize if my question has been asked many times. Please point me to the right article. Thanks.

I have an opportunity trigger that accepts or rejects changes (close date) based on today's date. I need to know how to temporarily set the today's date to a particular date while testing the trigger, similar to System.RunAs() method that allows me to execute codes under a certain user's profile, except this is to "pretend" the codes are executed on a particular date?. Can someone show me the trick?

Thanks.

=Alex
Does anyone have experience in writing a report in Visualforce page with custom controller? There are certain limitations (due to custom objects) that the default Salesforce Reports module cannot do (mostly cannot join tables).

Right now we export data to BO and generate reports from there. We have difficulty dealing with currency fields in the BO reports due to multiple currency exchange rate.

Please share your experience.

Thanks.
In an Account detail page, I created a custom button in the Opportunity related list to execute Javascript. How can I pass the (string) value of GETRECORDIDS to another s-control when calling window.open()?

Here is my Javascript:
Code:
var idstr={!GETRECORDIDS($ObjectType.Opportunity)};
alert(idstr);
window.open("{!URLFOR($SControl.MySControl, Account.Id, [oppIds=idstr])}","","top=100,left=100,width=400,height=400,status=yes,toolbar=yes");

I get an error indicating "idstr" doesn't exist.

Any help/pointer will be appreciated.

Thanks.

Can someone show me how to retrieve the Task.subject picklist values in s-control, please?

Thanks.


Message Edited by okaylah52 on 08-19-2008 03:38 AM
I remember I read from somewhere regarding using s-control with Salesforce.com standard user interface. Unfortunately I can't remember where. Can someone point me to the right article or user's guide?

Thanks a lot
I have a custom Visualforce page to replace the Account detail page. But I want this page to be available to a certain group of users.

I have few customized Account layouts (HK, AU, JP, etc) and I want my custom page in a particular account layout (say, in JP). How can I configure my layout, button, etc? We use record type and profile for each region/country.

Thanks.
Hi,

I need a requirement to have checkboxes across rows (in a list). I need to capture the checked checkbox values in my controller.

I studied the example presented in the Visualforce Developer's Guide (selectCheckBoxes, selectOptions). It seems the sample works if all checkboxes are grouped in a single row. But when I try to have a single chexkbox per row, I can;'t get it to work.

Please advice. Thanks.

Here are my codes (based on the developer's guide). Please pardon the indentation.

My VF page:
Code:
<apex:page controller="sampleCon">
<apex:form >
<apex:pageBlock >
<apex:pageBlockTable value="{!items}" var="item">
<apex:column >
<apex:selectCheckboxes value="{!countries}">
<apex:selectOption value="{!item}"/>
</apex:selectCheckboxes>
</apex:column>
</apex:pageBlockTable>
<br/>
<apex:commandButton value="Test" action="{!test}" rerender="out" status="status"/>
</apex:pageBlock>
</apex:form>
<apex:outputPanel id="out">
<apex:actionstatus id="status" startText="testing...">
<apex:facet name="stop">
<apex:outputPanel >
<p>You have selected:</p>
<apex:dataList value="{!countries}" var="c">{!c}</apex:dataList>
</apex:outputPanel>
</apex:facet>
</apex:actionstatus>
</apex:outputPanel>
</apex:page>

 
My Controller:
Code:
public class sampleCon {
String[] countries = new String[]{};
public PageReference test() {
return null;
}
public List<SelectOption> getItems() {
List<SelectOption> options = new List<SelectOption>();
options.add(new SelectOption('US','US'));
options.add(new SelectOption('CANADA','Canada'));
options.add(new SelectOption('MEXICO','Mexico'));
return options;
}
public String[] getCountries() {
return countries;
}
public void setCountries(String[] countries) {
this.countries = countries;
}
}

 

I am writing a Visualforce page using apex tags.

I have an inputField in a pageBlockSection (1 column).
How can I configure the inputField dimension which is bound to a text field which allows multiple lines (e.g. Task.Description) in my controller?

For example: in HTML code, I can write something like "<textarea rows="20" columns="80">". Can I do the same using apex:inputField? If not and I have to de-couple the label and the input field (using inputTextArea), then how can I bind the value to my variable in my controller? Do I need some kind of Javascript or Ajax to do the job?

Thanks.
Let say I am in an s-control, i have a line (Javascript) something like below:

var task = new sforce.SObject("Task");

When I get the task, which fields are auto-filled? (and filled with what values?)

If there a documentation on default values returned by sforce.SObject() for each object type, e.g. Account, Opportunity, Task, etc?

Thanks.
I have a requirement to pop up a new window from a list view.

Here is the scenario: I am viewing an account detail page. From the Opportunity section (list view), I want to be able to check off a few items, then click a custom button that will pop up a window, list the opportunities (name) I selected, has a text area to enter a note, then submit. The note will be attached to all selected opportunities.

I know I can pop up a window from a detail page, but there is no way to pop up a new window from a list view.

From a list view, how can I pop up a new window that contains a form, be able to submit the form and retrieve form values for updating?

Thanks.


Hi All,

I am a newbie.

Before inserting or updating an opportunity, I have a trigger that fires and checks for a certain condition, i.e. the opportunity company must have at least a contact. If the trigger throws an exception, how can I catch the exception in the Opportunity panel/page so that i can display an alert instead of an ugly message seen below?

Error: Invalid Data.
Review all error messages below to correct your data.
Apex trigger CheckContactTrigger caused an unexpected exception, contact your administrator: CheckContactTrigger: execution of BeforeInsert caused by: MissingCompanyContactException.MissingCompanyContactException: The company "Rajan Co" must have a contact.: Trigger.CheckContactTrigger: line 7, column 18

 If an alert is not possible, then how can I make the error message looks nicer (just show the exception message) like below?

Error: Invalid Data.
Review all error messages below to correct your data.
The company "Rajan Co" must have a contact.

If you have a better idea, please share it here.

Thanks.

We installed a package we developed. But now we want to remove the package but we still want to keep all components, e.g. Apex classes, triggers, custome fields, etc in tact. Can we just remove everything from the package using the Remove option in the Package Detail/Package Components section?

 

Thanks.

Let me begin by saying that I can click to program (not a programmer).

 

I have designed a very basic survey form that I would like to display to customers so they can submit a review and then be redircted to a thank you page. I do not know how to execute the redirect when they click submit. I am using the following code to Save the record.

 

      <apex:pageBlockButtons >
          <apex:commandButton action="{!save}" value="Submit Questionnaire"/>
      </apex:pageBlockButtons>

 

The site is enabled and I can view the form and fill in all of the fields, however, when I click Submit the following error page is displayed, "Page Not Found {VisualForcePage}/{Record ID}"

 

I know that the guest user doesn't have permissions to view the detail record which is why they receive the "Page Not Found..." message and I don't want them to view it, I want them to be redirected to a second Visualforce Page that essentially says, "Thank You."

I have a list of SObjects. I pass the list to a utility method to check. In the method, it calls addError() of an SObject. How can I retrieve or go through the list and check which item has an error?

 

Thanks.

Good morning,
 
I wrote a testMethod, in which I use a runAs user, like:
Code:
                Profile pr2 = [select id from profile where name='Standard User'];
                User u = new User(Manager=OTHERTESTUSER,alias = 'standt', email='standarduser@testorg.com',emailencodingkey='UTF-8', lastname='Testing', languagelocalekey='en_US',localesidkey='en_US', profileid = pr2.Id,timezonesidkey='America/Los_Angeles', username='standarduser@testorg.com');

                System.runAs(u)
                {...}

 
I want to set an other TestUser as the Manager of RunAs User....is that possible ?
 
I have attempted to create and insert a new User before the System.runAs statement, but that works somehow not..hmm.
 
Thanks a lot in advance for help!
Peter
How can I override a delete link/command in a related list? Or is there a trigger related to CampaignMember table?

I am interested in particular overriding the delete link/command of the Campaign Member Extras related list in the Campaign detail page or of the Campaign History related list in the Contact detail page.

(I want to detect if a CampaignMember is created or deleted, then I update Account object accordingly)

Thanks.

(Crossed out incorrect info. Campaign Member Extras is my custom object in my attempt to have extra campaign fields since we can't have custom fields in CampaignMember)


Message Edited by okaylah52 on 01-08-2009 05:23 PM
We have a setup where there is a custom object called Competitor.
On our Opportunity page, we have a lookup table field called Primary Competitor (a required field) to the Competitor object called Primary Competitor.
 
I have written a trigger on the Opportunity object that does some evaluations when an Opportunity is inserted/updated.
 
I wrote up a test method to test the trigger. However, I get the following error:
INSUFFICIENT_ACCESS_ON_CROSS_REFERENCE_ENTITY, insufficient access rights on cross-reference id
 
 
Basically, this is the code of the test method:
Integer size = 5;
List<Opportunity> opp = new List<Opportunity>();
for (Integer i = 0; i < size; i++)  {
   Opportunity o = new Opportunity();
   o.ownerId = '00530000000kFvU';
   o.name = 'Opportunity Test: ' + i;
   o.Primary_Competitor__c = 'a1K50000000Caz4EAC';
   o.accountId = '0015000000L3FPk';
   o.closeDate = System.today() + 150;
   o.stageName = 'Quotation';
   opp.add(o);
}
insert opp; 
 
When I run the test method I get the error listed above. If I comment out the line that adds the Primary Competitor to the Opportunity, then I do not have the error.
 
I've been looking around as to why the error is happening but I'm not having any luck in solving it. Any advice would be appreciated.
 
Thanks in advance
Warren
Hi All,

I apologize if my question has been asked many times. Please point me to the right article. Thanks.

I have an opportunity trigger that accepts or rejects changes (close date) based on today's date. I need to know how to temporarily set the today's date to a particular date while testing the trigger, similar to System.RunAs() method that allows me to execute codes under a certain user's profile, except this is to "pretend" the codes are executed on a particular date?. Can someone show me the trick?

Thanks.

=Alex
I have one DateTime field and i have used VF Page for that object..
Now i want to use Datepicker in VF Page. is it possible?
how can i do this?

Thanks
Hi,

In a visualforce page I have a need for displaying picklist entries. The problem is that this field depends on another picklist field. Is there a way to get to the dependencies somehow ?

I'm stranded at :

Code:
for(Schema.PicklistEntry p:Schema.sObjectType.Case.fields.getMap().get('Dependent_Field__c').getDescribe().getPicklistValues()) {
     System.debug(p.getValue());
}

 
This gives me all the values. However, I would like to be able to single out the values that correspond to a certain value in the controlling field ...



Thanks for your help,


David
Hi,

Can I use the static resource in a s-control ?

Like,
Code:
<script type="text/javascript" src="{!Resource.Companies}"> </script>

 
If no, is there a simpler way to use a .js file from the s-control. I have lot of functions defined in a .js file and I want to re-use them in multiple s-controls. Could someone pls let me know how I can do this.

Thanks


Does anyone have experience in writing a report in Visualforce page with custom controller? There are certain limitations (due to custom objects) that the default Salesforce Reports module cannot do (mostly cannot join tables).

Right now we export data to BO and generate reports from there. We have difficulty dealing with currency fields in the BO reports due to multiple currency exchange rate.

Please share your experience.

Thanks.
Does anyone know the best way to get checkboxes in a data table-like format?

The end result should be a 'related list' like structure, but with a checkbox in the left-most column.
I've tried "apex:selectCheckboxes" but need to display more than just a label.

And I've tried "apex:pageBlockTable" with an inputCheckbox in the first column, but I don't know how to get the controller to recognize which rows were checked and which not...

Can you help?

Thanks
  • September 08, 2008
  • Like
  • 0
Hello all,

I'm trying to retrieve the picklist value of  different quoteLines using a query and then set a field to "Yes" in case there is at list one picklist value equals to "Service & Other".

Product_Family__c is the picklist field.

the problem is that records[i] holds more data than the picklist value itself.


Code:
var soql = "select Product_Family__c  from SFDC_520_QuoteLine__c where Quote__c = '{!SFDC_520_Quote__c.Id}'";
var queryResult = sforceClient.Query(soql);

var records = queryResult.records;
var flag = true;
for(var i=0;i<records.length&&flag;i++)
{
 if(records[i]=="Service & Other")
 {
  upd.set("PSO_Needed__c","Yes");
  flag = false;
 }
}

how can I get the picklist value itself?

Thank you all.

Assaf
 



Message Edited by Assaf on 09-10-2008 11:38 PM
  • September 07, 2008
  • Like
  • 0
We are creating a PDF document using Visual Force Page and the document has a logo ( a png or gif image file on header). Currently the image file is a static resource and using merge field the VF page is able to display it correctly. When we do the packaging the resource is also packaged and is getting installed without any issues.

 

Now we want to change the logo at the installed org , as the logo was bundled as static resource it cannot be modified so, we are trying to place the image in a document folder and refer it  in VF page but the image is not displaying correctly .  We have tried using  url for the image but it is not working . Your help or a working example  will be appreciated in resolving this issue.

 <apex:image value="{!$Resource.gii__logo}"/>

We are trying to package the application as managed beta. The static resources gets locked in the target org.

So we are not able to change the logo.

Is there any way we can use a logo file from the document folder in

We already tried using the URL <apex:image url="/document/image/logo.jpg"/>.  But it does not work..

Is there any way to get the URL for the documents within the org itself.


**This is very urgent, **  Your help is much appreciated



  • September 05, 2008
  • Like
  • 0
I have a custom Visualforce page to replace the Account detail page. But I want this page to be available to a certain group of users.

I have few customized Account layouts (HK, AU, JP, etc) and I want my custom page in a particular account layout (say, in JP). How can I configure my layout, button, etc? We use record type and profile for each region/country.

Thanks.
I have went through the Apex Language Reference and the Force.com Cookbook but could not find any in depth explanation of how to test Apex code.
 
The only thing I understand from reading these two sources is that in order to deploy to Apex to production at least 75% of the code must be covered in the test.  Then they give a couple of examples of testing code.  But there doesn't appear to be any explanation as to why the test examples use the keywords and methods that they are using.
 
What other sources are there that can further explain in depth how to test Apex?
 
-Thanks
   
In a testMethod, I have following code:

Account_Auditor__c Account_auditor = new Account_Auditor__c(Account__c = a.id, auditor__c = u.id, Audit_Type__c = 'Garbage');
insert Account_auditor;
The intent is to execute the following trigger and give the "Auditor" read rights to the Account .

The testMethod runs fine in developer org, it croaks in the org that it is being installed it - it croaks on the Insert statement with the message:

caused by: System.DmlException: Insert failed. First exception on row 0; first error: INSUFFICIENT_ACCESS_ON_CROSS_REFERENCE_ENTITY, insufficient access rights on cross-reference id

trigger grantAuditorReadAccessToAccount on Account_Auditor__c (after insert) {

Account_Auditor__c[]  Account_auditor_list = trigger.new;

for (Account_Auditor__c Account_auditor: Account_auditor_list) {
AccountShare ashare = new AccountShare();
ashare.AccountAccessLevel = 'Read';
ashare.OpportunityAccessLevel = 'None';
ashare.CaseAccessLevel = 'None';
ashare.AccountId = Account_auditor.Account__c;
ashare.UserorGroupId = Account_auditor.Auditor__c;
Insert ashare;
}
}

I suspect it has something to do with the user rights - I am fetching an active user from the database in the test method (u.id). In the org that I am installing, I have two users, one is system admin, another is a test user I created, so that i could install. I assume I am installing as a


Hello,

I have developed a Apex test case that tests a trigger.
This test case needs to run as another user whose role is different from "System Administrator".
How would I do that? Does Apex have the equivalent of runAs()?

Andi Giri
  • March 21, 2008
  • Like
  • 0