• OnDem Dev
  • NEWBIE
  • 105 Points
  • Member since 2008

  • Chatter
    Feed
  • 4
    Best Answers
  • 1
    Likes Received
  • 0
    Likes Given
  • 103
    Questions
  • 80
    Replies

Hi all,

 

If anyone could offer some advice I'd really appreciate it.  My trigger is getting the following error: 

Apex script unhandled trigger exception by user/organization: 00540000000rfc7/00D300000000WHR

UpdateAssetNames: execution of BeforeUpdate

Caused by: System.Exception: Too many SOQL queries: 21

Trigger.UpdateAssetNames: line 20, column 20

The trigger updates associated Assets when an Account Name is updated.  I thought I'd set it up to process the records in bulk, but evidently I'm doing something wrong:

 

trigger UpdateAssetNames on Account (before update) {

 

// Assemble Accounts with new Names

 

Map<Id, Account> acctsWithNewNames = new Map<Id, Account>();

 

// Trigger.new - list of the Accounts

// Loop iterates over the list, and adds any that have new

// names to the acctsWithNewNames map.

 

for (Integer i = 0; i < Trigger.new.size(); i++) { if ( (Trigger.old[i].Name != Trigger.new[i].Name)) {

 

acctsWithNewNames.put(Trigger.old[i].id, Trigger.new[i]);

}

}

 

List<Asset> updatedAssets = new List<Asset>();

 

for (Asset a : [SELECT id, accountId, Name FROM asset WHERE accountId in :acctsWithNewNames.keySet()]) {

 

Account parentAccount = acctsWithNewNames.get(a.accountId);a.Name = parentAccount.Name;

 

updatedAssets.add(a);

}

update updatedAssets;

}

 Many thanks in advance!

 

Deb

Hi,

 

I am creating Visualforce Email Template. In that i want to construct the URL using a custom object.

For example : <<URL of the org>>/Object.id

 

How can we get the current orgs URL as different orgs have different domains like na1, na2, tapp0 ?

 

Can anyone help me in getting the organizations URL? 

 

Regards,

Imran

Hi,

 

I am using Private sharing model on a Custom object.

 

As a Non-Admin user, when i try to share the record to the other users with 'Edit' or 'Read' Access level in a Class which has "with Sharing" keyword, the following exception is thrown.

Field is not writeable: <<Custom Object>>__Share.RowCause

 

When i remove the "with sharing" keyword from the class, then it works fine.

 

Can any one tell what is the issue and what is the best solution.

 

Thanks in advance.

 

Regards,

OnDem

 

 

Message Edited by OnDem Dev on 01-18-2010 11:23 PM

My application has two profiles, one for Admin and other for Non Admin.

 

There is a Custom Object which is overriden with Visualforce page.

For Admin profile everything works fine.

 

In Non Admin Profile, if View Setup and Configuration permission is checked, accessing the above Custom tab and remaining functionality works fine. 

 

If View Setup permission is unchecked, Insufficient Privileges error message is shown.

 

Can anyone help me out in resolving this issue?

Note: I even tested by giving all the Custom Object Permissions but no luck.

 

OnDem

Message Edited by OnDem Dev on 01-12-2010 10:48 PM
Message Edited by OnDem Dev on 01-12-2010 10:52 PM

My application has two profiles, one for Admin and other for Non Admin.

 

There is a Custom Object which is overriden with Visualforce page.

For Admin profile everything works fine.

 

In Non Admin Profile, if View Setup and Configuration permission is checked, accessing the above Custom tab and remaining functionality works fine. 

 

If View Setup permission is unchecked, Insufficient Privileges error message is shown.

 

Can anyone help me out in resolving this issue?

Note: I even tested by giving all the Custom Object Permissions but no luck.

 

OnDem

Message Edited by OnDem Dev on 01-12-2010 10:43 PM
Message Edited by OnDem Dev on 01-12-2010 10:46 PM
Message Edited by OnDem Dev on 01-12-2010 10:53 PM

I would like to know which SObject field holds the detail of the Admin Access Exp Date.  

The above field can be exposed by editing the Users View.

 

 

Hi,

 

Can we find whether the logged in user is the actual User or the Admin who can log in after providing Grant Login Access?

 

Regards,

OnDem

Message Edited by OnDem Dev on 12-23-2009 03:32 PM

Hi,

 

Can we find whether the logged in user is the actual User or the Admin who can log in after providing Grant Login Access?

 

Regards,

OnDem

Hi,

 

How can i know the current login time of the User.?

 

Also is there anyway to find whether the Admin has logged in as a Proxy User

 

Regards

Message Edited by OnDem Dev on 12-15-2009 07:43 PM

Hi,

 

In my package, query to Opportunity object is made in which Current Generators, Main Competitiors are queried and shown in Visualforce page.

After doing Managed Release, and installing package in another instance.

When that Visualforce page is viewed, the Current Generators and Main Competitors fields are empty.

When i checked the fields of Opportunity object, each custom field like Current Generators is twice, one is default and other Managed Release.

 

So how can the value from the Current Generators and other Custom Opportunity fields be obtained.

 

Regards

 

Hi,

 

I am developing an application which uses Forecast hierarchy.

I made all the changes in the Forecast setting and Enabled the Customizable Forecast Hierarchy for the org.

 

Now when i queried the RevenueForecast object, found that its empty.

 

Can anyone help me what could be the reason and what should be done to overcome the issue?

 

Regards,

 

 

Hi,

 

I am using Forecast Hierachy in my org.

When a Users Forecast is viewed, it shows up all the Managers in that Users hierarchy in a section in the top.

 

I want to find all those Managers in the hierarchy for a particular User using SOQL query.

It can be done recursively, but may hit governor limits at some stage.

 

Is there any solution for this?

 

Regards,

Message Edited by OnDem Dev on 10-06-2009 06:17 PM
Message Edited by OnDem Dev on 10-06-2009 06:39 PM

Hi,

 

I used Apex code to initiate the Approval Process.

Once the record is submitted, the record gets locked.

I want to update the record now, but it does not allow doing that rather throws an exception ENTITY_IS_LOCKED, the entity is locked for editing.

 

Regards

 

Message Edited by OnDem Dev on 10-02-2009 09:51 AM

Hi,

 

All users in my org have the Manager field empty.

We are using Forecast Hierarchy in our org to share the data.

 

Now my requirement is to find Manager of a User using Forecast Hierarchy.

I am not using the Standard Role hierarchy.

 

Is there any solution to this?

Will ForecastShare object be of ay help in achieving this?

 

Any help on this will be highly appreciated.

 

Regards

Message Edited by OnDem Dev on 10-02-2009 01:02 AM

Hi,

 

I have a custom object on which i want to have restricted visibility access. So, i used Sharing settings and standard role hierarchy to achieve that.

But, There is a requirement where Standard Sharing settings should not be used, instead Forecast Sharing settings should be used.

 

Can i share the Custom object records using the Forecast Share?

 

Any help on this wil be highly appreciated.

 

Regards,

OnDem

 

Message Edited by OnDem Dev on 09-29-2009 12:43 PM
Message Edited by OnDem Dev on 09-29-2009 05:04 PM

Hi,

 

I have a PDF file which is uploaded as an attachment.

Now i want to render this PDF file in a Visualforce page.

I queried the attachment and used toString() method to get the String format.

But when i do this, the binary content is being displayed in the VF page.

 

How can the actual content be displayed on the VF page?

 

Any help on this will be highly be appreciated.

 

Regards,

OnDem

Hi,

 

HTML file is uploaded as an attachment.

When the body of Attachment object is queried and rendered in a Visualforce page as PDF, its displaying the entire html content with all the tags.

My requirement is that the HTML file should be viewed as PDF.

Can this be achieved?

 

Any help will be highly appreciated.

 

Regards,

OnDem

Message Edited by OnDem Dev on 09-02-2009 10:59 AM

Hi,

 

I am getting the below error when i try to save my Apex Controller.

 

line -1, column -1: Dependent class is invalid and needs recompilation: <Namespace.ApexClassName>: <line No> Didn't understand relationship '<Custom Object Name>' in field path. If you are attempting to use a custom relationship, be sure to append the '__r' after the custom relationship name. Please reference your WSDL or the describe call for the appropriate names.

 

I checked my WSDL file and could see the field in that Object.

 

Can anyone help me why is this issue being faced.

 

Regards,

OnDem

Hi,

 

On a Custom Object, I created a report that generates a chart. No i want this chart to be shown in a Visualforce pge.

But when itry to do this, the entire page with headers, tabs and footers get shown up.

 

Is there anyway that only the chart can be displayed in Visualforce page?

 

Regards,

OnDem

Hi,

 

On a Custom Object, I created a report that generates a chart. No i want this chart to be shown in a Visualforce pge.

But when itry to do this, the entire page with headers, tabs and footers get shown up.

 

Is there anyway that only the chart can be displayed in Visualforce page?

 

Regards,

OnDem

Hi,

 

I created Unmanaged package and uploaded it 2 days back.

 

Today when i tried to upload it again, its navigating to the home page with a message "No error information was found".

 

So what can be the reason for getting this error message.

Any help on this is highly appreciated.

 

Regards,

OnDem

Hi,
 
I created an application using features like Apex, Workflow and others in Developer Edition.
I created the package in Developer Edition and when i tried to install it in Salesforce trial account, i got an error during installation that Apex, Workflow, Triggers are the missing features in this edition.
 
So is there any other way that i can install my application in Salesforce trial.
Link for creating Salesforce Trial account is https://www.salesforce.com/form/trial/freetrial.jsp.
 
Any help on this will be highly appreciated.
 
Thanks,
OnDem


Message Edited by OnDem Dev on 10-02-2008 11:43 PM

As an application developer, you may run into a use-case where the application must run in system context ("without sharing"), thereby bypassing org sharing rules. You must ensure that the org administrator explicitly approves any such behavior. 


The recommended way of achieving this is by using the Force.com ESAPI: http://code.google.com/p/force-dot-com-esapi/  


You must first create a custom field (preferably boolean) only accessible by an Admin user that stores the preference (Bypass Sharing: Yes/No). Then at runtime, call one of the following functions to set with/without sharing based on that setting.
 
http://force-dot-com-esapi.googlecode.com/svn/trunk/doc/SFDCAccessController.html#setSharingMode%28SFDCAccessController.SharingMode%29
http://force-dot-com-esapi.googlecode.com/svn/trunk/doc/SFDCAccessController.html#SFDCAccessController%28SFDCAccessController.SharingMode,%20SFDCAccessController.OperationMode%29


The first approach is to set the sharing mode on an existing SFDCAccessController object. (such as used with the ESAPI.accessController() - this function returns a static SFDCAccessController object)


If (org admin setting is with sharing)

     ESAPI.accessController().setSharingMode(SFDCAccessController.SharingMode.WITH);

else

     ESAPI.accessController().setSharingMode(SFDCAccessController.SharingMode.WITHOUT);


// later in the code

ESAPI.accessController().updateAsUser(c, new List<Schema.SObjectField>{Contact.LastName});



The second approach is to use the constructor that allows setting the sharing mode. In this approach, create a SFDCAccessController object and set it to whatever sharing mode the org admin wants. 


SFDCAccessController ac = null;

If (org admin setting is with sharing)  

     ac = new SFDCAccessController(SFDCAccessController.SharingMode.WITH, SFDCAccessController.OperationMode.ALL_OR_NONE);

else

    ac = new SFDCAccessController(SFDCAccessController.SharingMode.WITHOUT, SFDCAccessController.OperationMode.ALL_OR_NONE);


// later in the code

ac.updateAsUser(c, new List< Schema.SObjectField>{Contact.LastName});


Note that in both cases you can also allow for inherit sharing.







 

Hi,

 

Assuming that Contact has a relationship to Account, and Account has a relationship to Owner (User), how do I get the information of the Owner when I query from the Contact?

 

I've constructed the following query base on the example of the documentation, it doesn't throw any error but I couldn't get the values for the Owner:

 

SELECT Id, Name, Account.Owner.FirstName FROM Contact;

 

 

Is the SOQL correct?

Hi,

 

I am using Private sharing model on a Custom object.

 

As a Non-Admin user, when i try to share the record to the other users with 'Edit' or 'Read' Access level in a Class which has "with Sharing" keyword, the following exception is thrown.

Field is not writeable: <<Custom Object>>__Share.RowCause

 

When i remove the "with sharing" keyword from the class, then it works fine.

 

Can any one tell what is the issue and what is the best solution.

 

Thanks in advance.

 

Regards,

OnDem

 

 

Message Edited by OnDem Dev on 01-18-2010 11:23 PM

I'm trying to do a very simple repleat on an object.  I've looked at several examples and so far I've been unable to figure it out.

 

To help me learn this platform I'm creating a very simple expense report.  The report is Expense_Report__c and it can contain the objects Expense_Item_c.  This is working great.

 

Now I'm trying to figure out how to generate a PDF that will show me the name of the expense report and list the expense items related to that expense report.

 

I've looked a several examples but can't quite figure out what seems like is pretty straight forward.

 

Here's my code:

 

<apex:page standardController="Expense_Report__c" showHeader="false" renderAs="pdf">
  <!-- Begin Default Content REMOVE THIS -->
  <h1>XX 2:<apex:outputText value="{!Expense_Report__c.Name}" /></h1>
 
  <apex:repeat var="item" value="{!Expense_Report__c.Expense_Item__r">
  <tr><td>item.name</td></tr>
  </apex:repeat>
    <!-- End Default Content REMOVE THIS -->
</apex:page>

  • January 13, 2010
  • Like
  • 0

My application has two profiles, one for Admin and other for Non Admin.

 

There is a Custom Object which is overriden with Visualforce page.

For Admin profile everything works fine.

 

In Non Admin Profile, if View Setup and Configuration permission is checked, accessing the above Custom tab and remaining functionality works fine. 

 

If View Setup permission is unchecked, Insufficient Privileges error message is shown.

 

Can anyone help me out in resolving this issue?

Note: I even tested by giving all the Custom Object Permissions but no luck.

 

OnDem

Message Edited by OnDem Dev on 01-12-2010 10:48 PM
Message Edited by OnDem Dev on 01-12-2010 10:52 PM

Hello everyone!

 

Crazy idea, Is It possible to convert an attached Word file to an attached PDF file?

 

Thanks in advance!!

Is it possible to resize an iframe within a VisualForce page? I have a script that would work, but the apex:iframe does not allow OnLoad()

 

<script language="JavaScript">

<!--

function autoResize(id){

    var newheight;

    var newwidth;

 

    if(document.getElementById){

        newheight=document.getElementById(id).contentWindow.document .body.scrollHeight;

        newwidth=document.getElementById(id).contentWindow.document .body.scrollWidth;

    }

 

    document.getElementById(id).height= (newheight) + "px";

    document.getElementById(id).width= (newwidth) + "px";

}

//-->

</script>

 

<IFRAME src=" " width="100%" height="200px" id="iframe1" marginheight="0" frameborder="0" onLoad="autoResize('iframe1');"></iframe>

 

Hello,

 

I have a visualforce page which I am passing data from into apex code and using input from the page to update an object.

 

In this example I have a table of data, each ending with a checkbox and a text field.  the text field is disabled until the user ticks the checkbox.  at that point, I use javascript to enable the text field.

When the user is done they click a submit button which calls apex code.

 

This all works fine when I dont have the javascript involved.  ie if the text box is always enabled, the data is passed and object updated fine, however when I do try and involve the javascript to enable/disable the text field as the checkbox is toggled, no data seems to be being passed from the text field and the object is not getting updated.  well, it is, just not that text field.

 

Does anyone have any ideas why this would be happening and if it cannot be fixed, is there another way to link the textfield to the checkbox?

 

Thanks

 

Steven

Hi,

 

Can we find whether the logged in user is the actual User or the Admin who can log in after providing Grant Login Access?

 

Regards,

OnDem

Hello,

 

I am facing an error while running the Apex code as:

 

System.Exception: Too many SOQL queries: 10001

 

Can anyone provide me with a solution for this.

I went through the docs  and the discussions for the governor limits but got confused by the posts . 

 

 

Could any one provide a solution to this :

 

 

Your help will be appreciated .... 

 

Thanks

shaan 

  • November 17, 2009
  • Like
  • 0

Hi,

 

As far as i know all the CRUD and FLS permissions on Custom object can be set in the profile.

Do we still require to check the CRUD and FLS in the Apex Code by using the getDescribe and FieldDescribe functions mentioned in the Apex doc.

 

Using With Sharing keyword, i guess its ensured that current Users Profile permission and Field level permissions are enforced.

 

Is it still required to check CRUD and FLS permissions in our Apex code?

 

Any help on this will be appreciated.

 

Thanks,

Force

 

Hi,

 

In my package, query to Opportunity object is made in which Current Generators, Main Competitiors are queried and shown in Visualforce page.

After doing Managed Release, and installing package in another instance.

When that Visualforce page is viewed, the Current Generators and Main Competitors fields are empty.

When i checked the fields of Opportunity object, each custom field like Current Generators is twice, one is default and other Managed Release.

 

So how can the value from the Current Generators and other Custom Opportunity fields be obtained.

 

Regards

 

Hi,

 

I am developing an application which uses Forecast hierarchy.

I made all the changes in the Forecast setting and Enabled the Customizable Forecast Hierarchy for the org.

 

Now when i queried the RevenueForecast object, found that its empty.

 

Can anyone help me what could be the reason and what should be done to overcome the issue?

 

Regards,

 

 

Hi,

 

All users in my org have the Manager field empty.

We are using Forecast Hierarchy in our org to share the data.

 

Now my requirement is to find Manager of a User using Forecast Hierarchy.

I am not using the Standard Role hierarchy.

 

Is there any solution to this?

Will ForecastShare object be of ay help in achieving this?

 

Any help on this will be highly appreciated.

 

Regards

Message Edited by OnDem Dev on 10-02-2009 01:02 AM