• Ankit Arora
  • ALL STAR
  • 8262 Points
  • Member since 2010
  • Senior Architect
  • Briskminds Software Solutions - PDO


Badges

  • Chatter
    Feed
  • 286
    Best Answers
  • 2
    Likes Received
  • 10
    Likes Given
  • 17
    Questions
  • 2058
    Replies
Hi.
I'm using function getContent(), to get blob of PDF page.

There are cases where the PDF is empty (blank page), and it's fine. The question how can I detect it.

-I cannot inspect the blob ,as the characters have no meaning....
-In the controller of the PDFpage I have such indication, but I cannot access it in the caller process.

Any suggestions?

PageReference page = new PageReference('/apex/PDFpage...');
blob bodyAttach=page.getContent();
Hello,

I want to merge 3 visualforce tabs in to one.
One solution is use radio buttons and let user select which data it should display.

But is there any better solution which will look better graphically like having tabs
Hi All,

Can anyone share the code snippet of Dependent Picklist using Dynamic Apex

Regards
If any one of you created the Force.com default Recruiting app. I have a simple yet weird question for you guys. I can't see any Job_Application object in the related to list.

Let's start by adding the master-detail relationship field, which will relate our Review object with the Job Application object. To create the master-detail relationship field, access the Review object detail page.

4. Select Master-Detail Relationship, and click Next.
5. In the Related To drop-down list, choose Job Application, and click Next.

So I'm stuck at 5th point. I have Job Application object created already, which have two relationships in it, one with Position object and the other one is with Candidate object. Pleas help.

In the trigger below, I am attempting to update a custom object called Instructors__c when a user changes.  I'm looking for specific criteria, if they've become inactive, and if they're in a specific department, otherwise I move on.  The issue however is that my update is throwing a MIXED_DML_OPERATION error.  I found references to the @future option, however I need to pass an object to test against with at least 4 elements, the User id, EmployeeNumber, Department and isActive flag.

I did try putting this into a separate function with @future using this as a reference: http://salesforce-evershine-knowledge.blogspot.com/2012/09/unsupported-parameter-type-in-future.html.  That solution had it's own set of issues and errors, namely passing in the information via the objects.  

Any thoughts would be greatly appreciated.

// Run this only on update
    if(Trigger.isUpdate == true) {
        
        // When we deactivate a user, check to see if they are in instructor department
        // if they are, take their exit date and add it to the instructor object
        // and set them to inactive on the instructor object as well.        

    // Department name that instructors belong to
   String department='Instruction';

        //MASS ERROR MESSAGE
        String ErrorMsg = '';

        List<Instructor__c> instructorsToUpdate = new List<Instructor__c>();
        // Loop through each user, in case there is more than one user passed in
        for(User theUser : trigger.new) {            

            // If we have an active user, and that user happens to be in instruction
            if(theUser.isActive == false && theUser.Department  == department) {

                try {
                    // Get the instructor from the instructor and update their record
                    Instructor__c theInstructor = [SELECT Id, TeacherActive__c, Employee_Departure_Date__c FROM Instructor__c WHERE TeacherEmployeeID__c = :theUser.EmployeeNumber LIMIT 1];
                    // Make sure we have an object before trying to work with or update it.
                    if(theInstructor != null) {
                        theInstructor.TeacherActive__c = false;
                        theInstructor.Employee_Departure_Date__c = theUser.Exit_Date__c;
                        // Optimization
                        instructorsToUpdate.add(theInstructor);
                        ErrorMsg = ErrorMsg + 'Instructor: '+theInstructor.Name+', departure: '+theInstructor.Employee_Departure_Date__c+'\n';
                    }
                } catch(System.QueryException e) {
                    System.debug('Failed to find Instructor: ' + e);
                    ErrorMsg += 'Croaked while attempting find Instructor in Instructors__c using employee number: '+ theUser.EmployeeNumber + '<br/>Error: '+ e + '<br /><br/>'; 
                }
            }
        }
        // Do the update on the list, not the individual for batch/optimization
        update instructorsToUpdate;


Error Message text: 

Error: Invalid Data.
Review all error messages below to correct your data.
Apex trigger User_AI caused an unexpected exception, contact your administrator: User_AI: execution of AfterUpdate caused by: System.DmlException: Update failed. First exception on row 0 with id a0UR0000003jSkcMAE; first error: MIXED_DML_OPERATION, DML operation on setup object is not permitted after you have updated a non-setup object (or vice versa): Instructor__c, original object: User: []: Trigger.User_AI: line 42, column 1

Hi folks,
      Can anyone tell me what are the profiles available for community ?
What's the purpose of those profiles?



Thanks in advance
Karthick
Hi All,

  I want create a Time-Dependent Workflow action, for updating the Product's Custom field 'Status' .
if Product-Stauts = 'New' then after 90days the status field must be updated to Old.

what will be the Rule-Criteria and Criteria-Evalution ?

Thanks  in Advance.
Cheers
Baba
How to add parent object fields in a child object's page layout ?
Installed a managed package, which contain simply 2 pages, controllers, stylles, scripts etc.
Then created a site using the apge within the pacjkage. When i clicked an action button, Recieved the exception , “List has more than 1 row for assignment to SObject
Error is in expression '{!saveingData}' in page donation:donationform: (Donation)
An unexpected error has occurred. Your solution provider has been notified. (Donation) “
What will be the reason? Anything regarding the installation or configuration.
Any help?
Thanks in advance.
  • August 27, 2014
  • Like
  • 0
Can we use rendered and rerendered in same vf page?
Please let me know how to display the SOQL query result in VF page in tabular form when the SOQL object type and the associated attributes are dynamic.




  • August 22, 2014
  • Like
  • 0
trigger custom1 on student__c (before insert)
{
list <student__c>st1= new list <student__c>();

for(student__c st:trigger.new)
{
   if(st.sport__r.name=='rugby')
    {
      st.stdno__c=12345;
   
}
insert st;
}
}
  • August 20, 2014
  • Like
  • 0
I'm getting an error and not able to find solution . I'm trying to use best practice of trigger using trigger handler . Following is what I did uptil now . Anyone please help me to structure or help me with modification .Thanks in advance.



===Trigger===

trigger OpportunityTrigger on Opportunity (after update) {
   new OpportunityTriggerHandler().run();
}

=== Trigger Handler class ===
public virtual class TriggerHandler {

  public TriggerHandler() { }
  
  // main method that will be called during execution
  public void run() {

     // dispatch to the correct handler method
      if(Trigger.isAfter && Trigger.isUpdate) {
      this.afterUpdate();
    } 
  }

  // context-specific methods for override
  protected virtual void afterUpdate(){}
  protected virtual void afterDelete(){}
    
  // exception class
  public class TriggerHandlerException extends Exception {}

}

== OpportunityTriggerHancler Class== 

I'm getting error in this class .
public class OpportunityTriggerHandler extends TriggerHandler {

   List<Task> tasks = new List<Task>();
   List<Opportunity> Opps = Trigger.new;
   Map <Id, String> oppsOwner = new Map <Id, String> ();
   
   public OpportunityTriggerHandler() {}
  
   protected override void afterUpdate()
  {
    for (Opportunity opp : trigger.new)
    {
        // Check if the StageName has been changed
        if (opp.StageName != trigger.oldMap.get(opp.Id).StageName)
        {
            // get the owner ID's that have been affected
            oppsOwner.put(opp.ownerId, null);
        }
    }

    // Map the owner ID to it's email address
    for (User owner : [SELECT Id, Email FROM User WHERE Id = :oppsOwner.keySet()])
    {
        oppsOwner.put(owner.Id, owner.Email);
    }
        
  }
   
  }


Hi All,

I am trying to write a query that export all the data of leads (the data that we need to export is available under (App Setup -> Customize -> Leads -> Fields), i am able to export some fields, but when trying to access some fields i am getting an SQL Error:

(No such column 'Address' on entity 'Lead'. If you are attempting to use a custom field, be sure to append the '__c' after the custom field name. Please reference your WSDL or the describe call for the appropriate names.)



this is the list of the fields that we need to export using our php code:

- Address

- AnnualRevenue

- Campaign

- Company

- CreatedBy

- Jigsaw

- Industry

- LastModifiedBy

- LastTransferDate

- Owner

- RecordType

- NumberOfEmployees

- Rating

- Title

- Correlation_Data

- CorrelationID

- ProductInterest

- Financial_Product

- IB

- iContact_Contact_Id

- Lead_Number

- Lead_Source_Details

- Lead_Type

- Web_to_x_Lead

- Web_to_x_form_id

- Preferred_Communication

- Round_Robin_ID

- Trading_Softwae

- VIP_Customer

- Web_Source

I appreciate your help

Hi Guys,

I have been working as a Salesforce Dev for 3 years in Administration,Apex, Visualforce,Javascript,CSS.

Now i wish to move to mobile app development in Salesforce. But i dont have any idea on how to get Started. 

I was working on a OMS Portal all these days.   Suppose i want to develop a similar OMS app in mobile where Customers can order  , how to get started?

Can someone provide me the link/pdf materials that will help us in starting with basics ? 

Thanks in Advance ! ! 

I want to prevent customer from posting comment on the chat feeder in Communities.

I got the trigger but it seem not right.  What is wrong here?

 trigger InternalChatterCommentTrigger on FeedComment (before insert) {
list<user> ExternalUser = [select id from user where ProfileId in('00e50000001FdBYAA0')];
FeedComment
     for (FeedComment fc : trigger.new){
             for(user u : ExternalUser){
                {
                 if (fc.CreatedById == u.id)
                 {
                   fc.adderror('You do not have permission to comment on Chatter. Please respond on this case using Comment related list');
    
        }
    }
}
}



hi all,

I am unable to understand the behaviour of the feature login hour restrictions.
If a users profile can login from 4pm to 5pm and a user logs in at 4.30 pm then what happens at 5.01pm?

Some have said that it automatically logs out,
some assume that the session goes on but he can only view.Once he tries for any DML operation,hez logged out

Can anyone help me out on this?

Thanks
<apex:page standardController="contact" sidebar="false">
<apex:form >
  <apex:pageBlock title="hello {!$User.FirstName}!">
   <apex:pageblockTable value="{!contact}" var="v" columnswidth="25,25,25,25">
    <apex:column value="{!v.name}"/>
       <apex:column value="{!v.lastname}"/>
          <apex:column value="{!v.phone}"/>
             <apex:column value="{!v.email}"/>
   </apex:pageblockTable>
  </apex:pageBlock>
</apex:form>
</apex:page>

list<account> alist=[select  count(name) from account where name like 'T%'];
for(account a:alist)
{
    system.debug('Records are:'+a);
}
  • August 16, 2014
  • Like
  • 0
Several openings for Jaipur location, interested candidate please send your resumes at info@briskminds.com

1) Fresher (3 opening) - Must know Java, JS, HTML

2) Salesforce experienced developer (one opening for 2-3 years of experience) - Must have worked on Apex, Visualforce, Integrations, W/F, Approvals and a little knowledge on communities is preferred

3) QA (one opening for 2-3 years of experience) - Must know automated testing (say selenium)

Please do respond ASAP, we need to fill these positions before October. Spread this to your friends who may be interested.

Thanks
Ankit Arora
Briskminds Software Solutions Pvt. Ltd.
http://www.briskminds.com/
Several openings for Jaipur location, interested candidate please send your resumes on info@briskminds.com

1) Fresher (3 opening) - Must know Java, JS, HTML

2) Salesforce experienced developer (one opening for 2-3 years of experience) - Must have worked on Apex, Visualforce, Integrations, W/F, Approvals and a little knowledge on communities is needed

3) QA (one opening for 2-3 years of experience) - Must know automated testing (say selenium)

Please do respond ASAP, we need to fill these positions before October. Spread this to your friends who may be interested.

Thanks
Ankit Arora
Briskminds Software Solutions Pvt. Ltd.
http://www.briskminds.com/

Strange problem :

 

Scenario is I have a Map (MyMap) in my controller class : Map<String , List<Account>>

 

Am trying to display this map values using visualforce page like this :

 

<apex:repeat value="{!MyMap}" var="M">
	<apex:repeat value="{!MyMap[M]}" var="temp">
		<apex:outputLabel value="{!temp.Test_Curr__c}"/><br/>
	</apex:repeat>
</apex:repeat>

 

Test_Curr__c is currency field and it is displaying value like this 1234.0 using above code . But I want to display this as $1,234. Outputfield resolves my problem here.

 

If I take a simple list of account and display on visualforce using outputField then it displays the desired format ($1,234) :

 

<apex:repeat value="{!accLst}" var="acc">
       <apex:outputField value="{!acc.Test_Curr__c}"/>
</apex:repeat>

 

But when I modify my logic using Map it says "Error: Could not resolve the entity from <apex:outputField> value binding '{!temp.Test_Curr__c}'. outputField can only be used with SObject fields."

 

<apex:repeat value="{!MyMap}" var="M">
<apex:repeat value="{!MyMap[M]}" var="temp">
        <apex:outputField value="{!temp.Test_Curr__c}"/><br/>
</apex:repeat>
</apex:repeat>

 

Just wondering when am fetching the list of account from Map why it is giving me error?? I know the error very well as it is at compile time but want to know the reason behind the screen.

 

Thanks

Ankit Arora

Blog | Facebook | Blog Page

There are many Ideas and requirements to display image on native contact page, so this is what I have blogged :

 

http://forceguru.blogspot.com/2011/06/display-picture-in-contact.html

 

Thanks

Ankit Arora

Blog | Facebook | Blog Page

This is about how we can create visualforce page code with just button click. Hope this is helpful.

Isn't that good if we can create a visualforce page with just clicking some buttons.

 

Have a look http://t.co/LDiMEBy 

 

 

Thanks
Ankit Arora

 

May this is simple but bit strange to me. We know that full sandbox and production have identical ids, but I am facing a problem i.e. I have created some 180 reports on my sandbox and used it on different dashboards. Some of the source in dashboards are having drill down. Means when we are clicking on report from dashboard then some other report is opened.

 

I have created a change set in which I have included all reports and dashboards. Now when I have deployed the change set on production then all Ids of dashboards and reports are different from that of sandbox.

 

Which leads me to again change all the drill down report Ids on dashboards.

 

Problem is why the Ids of reports and dashboards are changed????

 

 

Thanks
Ankit Arora

 

I have a strange problem, let me explain you the scenario :

 

1) I have installed a managed package with namespace (ankit), it includes a object name Sling and two recordtypes "test1" and "test2".

 

2) Now I have done some custom development on my personal org where I have installed that package. I have created a test class which looks something like this :

 

 

@isTest
private class MyTestClass
{
    private static testmethod void testM()
    {
        ankit__Sling__c s = [select id from ankit__Sling__c limit 1] ;
        System.debug('s :::::: ' + s) ;
        
        List<RecordType> rt = [select id from recordtype where sobjectType = 'ankit__Sling__c'] ;
        System.debug('rt ::::: ' + rt) ;
        
        List<RecordType> rt2 = [select id from recordtype] ;
        System.debug('rt2 ::::: ' + rt2) ;
        
        System.assertEquals(rt.size() , 2) ;
    }
}

 

 

3) Now I simply create another package which is unmanaged and include this test class in it, automatically package object sling and its record types are included. Now I have created a package(Unmanaged), and its done successfully. Now I am checking the debugs it gives me proper data (two record types are returned in test class and assert is passed).

 

Note : Till now I have not create a namespace for my organization.

 

4) Now what I have done is created a namespace on my organization and try to upload the same package(unmanaged) again. This time my test class get failed and the problem is no record type is returned whose sobjecttype is 'ankit_sling__c'.

 

My second debug

 

 

System.debug('rt2 ::::: ' + rt2) ;

 returns two record type which is expected, just wondering why these record types are not returned when I am putting where clause condition "where sobjecttype = 'ankit_sling__c' "

 

 

Is this is a bug??? I have tried this on multiple orgs and faced same problem everywhere.

Any directions over this will be great.

 

 

Thanks
Ankit Arora

 

 

 Looking for a workaround to fetch name from sObject record like I have 

List<Sobject> sObj = Database.Query(dynamicQuery) ;
for(SObject obj : sObj)
{
      //I can do this
      System.debug(' :::::::: ' + obj.Id) ;
     // Looking to do this
     System.debug('::::::::::::: ' + obj.Name) ;
}

 

I know the SObject name lets say account but I do not want to type cast mt result like this

List<Sobject> sObj = Database.Query(dynamicQuery) ;
for(SObject obj : sObj)
{
     Account acc = (Account)obj ;
}

 

Any help regarding this would be appreciable

Thanks
Ankit Arora

 

Hi All,

 

I have posted some of the sample questions for 401 certification exam. Also how you can prepare for the exam.

Will soon post some more interesting topics related to certification exam.

 

Click for Smaple Questions

And How To Prepare

 

Thanks

Ankit Arora

Blog | Facebook | Blog Page

@All Admins,

 

I have registered for a pre-release DE org using this URL , please let me know for how many days it will remain active. Is it 30 days?

 

Thanks

Ankit Arora

Blog | Facebook | Blog Page

Hi All,

 

Some time we need to display a good amount of data on our custom pages and pagination is the best option we can arrange that data on our custom VFP.

 

So question come how we can do that with salesforce native look and feel.

 

Here is the answer : http://forceguru.blogspot.com/2011/04/pagination-in-salesforce.html

 

Thanks

Ankit Arora

Blog | Facebook | Blog Page

Please visit:

 

http://forceguru.blogspot.com/2011/04/saving-script-statements.html

 

for tips regarding how to reduce the script statements and some good logics in apex code.

 

Thanks

Ankit Arora

Blog | Facebook | Blog Page

Hi All,

 

Just want to know that is there any way to fire validation rule on any record delete (Only on delete). I don't want to use trigger for it.

 

Thanks

Ankit Arora

Blog | Facebook | Blog Page

Hi,

 

Is there any way to connect from Salesforce to bhoomi.

As there is way to connect from Bhoomi to salesforce, but i want to send data from salesforce to FTP VIA Bhoomi.

If any one know about this please reply.

 

Thanks in advance.

Hi,

 

Just want to know is there any way to get file from FTP server, or I have to use third party tool?

 

Thanks in advance.

Ankit Arora

Blog | Facebook | Blog Page

Several openings for Jaipur location, interested candidate please send your resumes at info@briskminds.com

1) Fresher (3 opening) - Must know Java, JS, HTML

2) Salesforce experienced developer (one opening for 2-3 years of experience) - Must have worked on Apex, Visualforce, Integrations, W/F, Approvals and a little knowledge on communities is preferred

3) QA (one opening for 2-3 years of experience) - Must know automated testing (say selenium)

Please do respond ASAP, we need to fill these positions before October. Spread this to your friends who may be interested.

Thanks
Ankit Arora
Briskminds Software Solutions Pvt. Ltd.
http://www.briskminds.com/
Several openings for Jaipur location, interested candidate please send your resumes on info@briskminds.com

1) Fresher (3 opening) - Must know Java, JS, HTML

2) Salesforce experienced developer (one opening for 2-3 years of experience) - Must have worked on Apex, Visualforce, Integrations, W/F, Approvals and a little knowledge on communities is needed

3) QA (one opening for 2-3 years of experience) - Must know automated testing (say selenium)

Please do respond ASAP, we need to fill these positions before October. Spread this to your friends who may be interested.

Thanks
Ankit Arora
Briskminds Software Solutions Pvt. Ltd.
http://www.briskminds.com/
I have account Detail Page custom button and Content Source is visual force page in the Button Setup.
VF page is used to call a controller method to execute and create Record in ERP system using REST API.
<apex:page standardcontroller="Account" extensions="CreateCustomerController" action="{!createCustomer}">
</apex:page>
When user double clicks it is creating duplicate customer records in our ERP system.

How can I prevent this happening.? 
Can I disable the button after first click? 
If you have asome other solution I can try. I have seen some post like below but I am using VF page as content source so don't want use this.
https://developer.salesforce.com/forums/?id=906F000000093GUIAY


 
  • November 04, 2015
  • Like
  • 0
HI all, 

Trying to figure this VR but no luck. 

Need a VR Rule where it applies to all profiles except system admin, when the Opportunity ID record type =
012d0000000XJyv, and StageName = Conversion, with any values selected from picklist ADO Type = Grow, Mix, or Share, and need to make sure that number field ADO Actual is not blank. 

These parameters should prompt the user to enter data in the ADO Actual field.

 
AND( 
NOT($Profile.Name ="System Administrator"), 
OR( 
RecordType.ID = "012d0000000XJyv"), 
OR(
(ISPICKVAL(StageName, "Convert
(ISPICKVAL( ADO_Type__c , "Grow")),
ISPICKVAL( ADO_Type__c , "Mix"),
ISPICKVAL( ADO_Type__c , "Share")),
AND( 
NOT(ISBLANK(ADO_Actual__c)),
)

 
Hi All,

In one of our orgs we are able to access the 'list view buttons', Case detail page buttons etc.. from visualforce Home page component through jquery. As per 'winter 16' this privilage has been stopped from salesforce, when we try the same in our any other orgs the cross domain error is popping, this happens when we try to access the parent page buttons from Vf home page component. Could any one can explain what might be the reason for this or is there a special permission or provision from salesforce which is allowing this behavior, i couldn't makeout any help is highly appreciated

Thanks,
Harshavardhan
I've created a few action buttons to update the current record which works fine - but my main concern is trying to rename each action. I've asked a Saslesforce rep but they have no idea. If anyone out there can help me, that'd be great! 
how to display the account details into the map which is shown in vf page please help me?
sir/mam,   i wrote a after trigger code for :-  if the amount is greater than 50,000 then the opportunity record should be shared with another user, so i in program at query i took the user-id  where euals to ALIAS name.   this is working fine.   But problem is if write the query for LASTNAME instead of ALIAS name, then i am getting error,, please help.....
 
trigger afterinsertTrigger on Opportunity (after insert) {
list share=new list();
     user u=[select id from user where lastname='pogiri'];
    for(Opportunity op:Trigger.New){
        if(op.amount>50000){
            Opportunityshare s=new Opportunityshare();
            s.OpportunityId=op.id;
            s.OpportunityAccessLevel='Edit';
            s.RowCause='Manual';
            s.UserOrGroupId=u.id;
            share.add(s);
        }
    }
      insert share;
}


User-added image
 
Hi 
is used to represent the report in Piechart,is there any way to represent the report in Bar chart???
  • June 23, 2015
  • Like
  • 0
Batch and Schedule apex runs Sychorously or Asynchronously?
 
I am having a scenario where I need to map the Text value to picklist like below. Can some one guide me how to do it

On VF page Picklist values Enter Color radio button option a and radio button option B

 but if they want to enter any other color than this we give them input text to enter manually and we want to map that input text to this picklist in database. How can I do that?
Hi,

When ever a CaseMilestone is updated, I want to Insert/Update the Milestone data into a Custom Object.

As far as i know we cannot write a Trigger on CaseMilestone object.

Please suggest some solution to acheive this.

Thanks
Hi,
What’s the maximum batch size in a single trigger execution ?
Hi,

How can I check a particular field's dependencyin the org.

To ensure dependency I have tried to delete the field but it is not the foolproof solution as some dependecies, like reports etc., are not getting covered in that.

SO what is method by which I can garuntee that a metadata (especially a field) is used /have dependency in all other metadata?

Eg: A field XYZ is used in a class, VF page, validation rule, report etc.
So I need the list wherever this XYZ field is used.


Hope my query is clear, but do let me know if any further information is required.


Thanks,
Ritik


 
  • June 18, 2015
  • Like
  • 0
hi i have a task when we deactivating a user,the ownership of all the records owned by this user has to changed to his manager by using trigger.can any body please help for the code that need to be write for the trigger
Hi.
I'm using function getContent(), to get blob of PDF page.

There are cases where the PDF is empty (blank page), and it's fine. The question how can I detect it.

-I cannot inspect the blob ,as the characters have no meaning....
-In the controller of the PDFpage I have such indication, but I cannot access it in the caller process.

Any suggestions?

PageReference page = new PageReference('/apex/PDFpage...');
blob bodyAttach=page.getContent();
Hi all,

Clone is a standard button or Custom button.If it is custom button can any one provide me code behind the clone button for cloning particular records.

thanks
Hello,

I want to merge 3 visualforce tabs in to one.
One solution is use radio buttons and let user select which data it should display.

But is there any better solution which will look better graphically like having tabs
Assuming I've 2 users in my org: [User A] & [User B]

Assuming I've a Managed Package CustomObject: [abc__XYZ__c]

IMPORTANT:
  • [User A] - has been assigned a License of this Managed Package.
  • [User B] - DO NOT have a User License to this Managed Package.

Consider these 3 Visualforce Pages & respective Apex Classes:
  • Test1
  • Test2 / Test2Controller
  • Test3 / Test3Controller

Code for the Pages/Classes is as follows:

Test1 VF Page:
<apex:page standardController="abc__XYZ__c">
    <apex:pageBlock>
        <apex:pageBlockSection columns="1">
            <apex:outputField value="{!abc__XYZ__c.Name}" />
            <apex:outputField value="{!abc__XYZ__c.abc__TotalAmount__c}" />
        </apex:pageBlockSection>
    </apex:pageBlock>
</apex:page>



Test2 VF Page:
<apex:page controller="Test2Controller">
    <apex:pageBlock>
        <apex:pageBlockSection columns="1">
            <apex:outputText value="{!mysObjVar['Name']}" />
        <apex:outputText value="{!mysObjVar['abc__TotalAmount__c']}" />
        </apex:pageBlockSection>
    </apex:pageBlock>
</apex:page>



Test2Controller APEX Class:
public with sharing class Test2Controller {
    public abc__XYZ__c mysObjVar { get;set; }

    public Test2Controller() {
        mysObjVar = new abc__XYZ__c();
        abc__XYZ__c[] b = [select Id, name, abc__totalamount__c from abc__XYZ__c where id =: ApexPages.currentPage().getParameters().get('id')];
        if (b.size() > 0)
            mysObjVar = b[0];
    }
}



Test3 VF Page:
<apex:page controller="Test3Controller">
    <apex:pageBlock>
        <apex:pageBlockSection columns="1" title="via sObject">
            <apex:outputText value="{!mysObjVar['Name']}" />
            <apex:outputText value="{!mysObjVar['abc__TotalAmount__c']}" />
        </apex:pageBlockSection>
        <apex:pageBlockSection columns="1" title="via Custom">
            Name: <apex:outputText value="{!sName}" />
            Total: <apex:outputText value="{!sTotal}" />
        </apex:pageBlockSection>
    </apex:pageBlock>
</apex:page>



Test3Controller APEX Class:
public with sharing class Test3Controller {
    public sObject mysObjVar { get;set; }
    public string sName { get;set; }
    public decimal sTotal { get;set; }

    public Test3Controller() {
        mysObjVar = Schema.getGlobalDescribe().get('abc__XYZ__c').newSObject();
        string recordid = ApexPages.currentPage().getParameters().get('id');
        sObject[] b = database.query('select Id, name, abc__TotalAmount__c from abc__XYZ__c where id =: recordid');
        if (b.size() > 0) {
            mysObjVar = b[0];
            sName = (string) b[0].get('Name');
            sTotal = (decimal) b[0].get('abc__TotalAmount__c');
        }
    }
}



Now:
  • If I access, via [User A]: Test1, Test2, and Test3 VF pages in browser with a valid Record Id, I get ALL these 3 VF pages show me Values for the fields I have shown.
  • If I access, via [User B]:
    • Test1 VF page show "Insufficient Privileges" error.
    • Test2 VF page show me Empty Page.
    • Test3 VF Page show me Empty Section when access via sObject[fieldName] BUT show me Actual Values in field in a section when I use String Property to fetch the field values (image attached)
User-added image


And so my question, how can a User who does not have a License to the Package be able to Fetch Data, and be able to display it to user via a Custom Property, but not via an sObject instance variable or direct object instance variable?

To me it seems like a big Bug in platform! Ideally I don't think it should every allow reading of Data to any User who does not have access to the Managed Package via Licenses and Describe() Calls should respect that, shouldn't they?
  • February 05, 2015
  • Like
  • 2
I have a custom component below which has many attributes:
<c:SampleComponent sortBy="Type" storeTo="page2:hidden" isTableFormat="true"/>
How will I know which of the setter methods of each attributes executes first? Thanks!
Hi All,

I have plan to get apex percentage used in salesforce through codding. So, for this I am trying to get size without comments from each apex class or currently using characters from apex.

If we able to get directly apex percentage used, then no issues, my problem will solve.

Can you please help me any one on this.

Please find attached image for more details.

Thanks 
VenkatUser-added image
Hi, 

I have a problem that I'm finding hard to figure out. Any help on the issue would be most welcome. 

I have a custom object called Bonus, this has a lookup relationship with another custom object called Payments. 

Using a VF page and standard controller with extension, I have a button on the Bonus page layout that will create 4 payment records for a single Bonus record when pressed. 

This all works fine, however if I refresh the page immidiately after creating the Payment records, I get 4 more. If I close the page, open it again and then refresh I do not get any duplicates. 

Has anyone ever experienced this before? ...or have any suggestions for how I can troubleshoot?

Many thanks!
Hi I Want to get "Percent of Apex Used: XX.XX% " and need to send email at perticular level.

Can you please help on this?

Below queries are using for getting but not able to get correct result(These are tooling api objects).

1. SELECT Sum(LengthWithoutComments) FROM ApexClass WHERE ID NOT IN (SELECT ApexTestClassId FROM ApexCodeCoverage)
2. SELECT Sum(LengthWithoutComments) FROM ApexTrigger

I am doing sum of these two result.((Sum(1+2)/10000000)*100)

Thanks
Venkat
I have seen threads with dozens of questions about this over the last 6-7 years, all with the answer of "can't be done".  But, I keep hoping that each new version of SFDC might include a way of accomplishing it, so I'll ask the question once again.

I would like to use SOQL to query a parent object based on whether it does or does not have any child records (whether MD or Lookup).

The perfect query would be something like: 
- SELECT Id FROM Account WHERE COUNT(Contacts__r) = 0
or
- SELECT Id FROM Account WHERE Contacts__r.size() = 0
or
- SELECT Id FROM Account WHERE Contacts__r = null

From what I have found in threads as late as 2013, this does not appear to be possible.

Is that still the case in the Summer 2014 release?

It would appear that (for my needs) the best way to execute this type of query would be to:
- SELECT Name, (SELECT name FROM Contacts) FROM Account
- Then programmatically check the size of the returned set of Contacts

Is this my best option?  I know that I could:
- SELECT Id, Name FROM Account WHERE Id IN (SELECT AccountId FROM Contact)
But the actual objects that I want to interogate are more that the 50k limit for this type of query.

Thanks.

Bryan Hunt
I'm trying to run a location based SOQL query from javascript, using the AJAX toolkit, and I'm getting an error telling me that the location field is not defined. I have geolocation field, called Location__c, defined on the Contact. Here is my code:

<apex:page >
    <script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.1/jquery.min.js"></script>
    <script type="text/javascript" src="../soap/ajax/25.0/connection.js" ></script>
    <script type="text/javascript">
        $(document).ready(function() {
            sforce.connection.sessionId = '{!$Api.Session_ID}';
            var query = "SELECT Id FROM Contact WHERE DISTANCE(Location__c, GEOLOCATION(42.0, -76.0), 'mi') < 10";
            console.log(query);
            var res = sforce.connection.query(query);
            console.log(res);
        });
    </script>
</apex:page>

The post request is returning a 500 error, with the message, "No such column 'Location__c' on entity 'Contact'." However, there is a field called Location__c; furthermore, this query works just fine from the Developer Console. Can anyone see what might be going on here?
  • August 20, 2014
  • Like
  • 1
hi all,

I am unable to understand the behaviour of the feature login hour restrictions.
If a users profile can login from 4pm to 5pm and a user logs in at 4.30 pm then what happens at 5.01pm?

Some have said that it automatically logs out,
some assume that the session goes on but he can only view.Once he tries for any DML operation,hez logged out

Can anyone help me out on this?

Thanks
Hi folks
       Can anyone tell me what is trigger.oldmakp.keyset() and give me sample example for that

Please Help

Hi All

 

A new article has just been published on Developer Force:

 

  • An Introduction to Environments (link) - There are several types of environments available to you while developing and testing on Force.com. This article provides an outline of these environments. It will discuss the various editions, best practices and design considerations, and recommend particular environments during the application life-cycle.

 

As always, any feedback is welcome.

 

Thanks,
Jon