• Sujila
  • NEWBIE
  • 80 Points
  • Member since 2015
  • SFDC Partner
  • Deloitte LLP

  • Chatter
    Feed
  • 3
    Best Answers
  • 0
    Likes Received
  • 1
    Likes Given
  • 0
    Questions
  • 7
    Replies
Hi,
I have a controller on my visualforce page and I am not able to build test data to cover for the coverage for the below variables. The data comes in from my visualforce page. Can someone please advise?

public class OppExtension{
    public OppExtension(ApexPages.StandardController controller) {
        std = controller;
        OpptyRec = (Opportunity)std.getRecord();
}

public string s1{get;set;}
    public string s2{get;set;}
    public string s3{get;set;}

public PageReference assignvalue(){
        s1 = s1.replace('North America (%) : ', '');
        s2 = s2.replace('APAC (%) : ', '');
        s3 = s3.replace('LATAM (%)  : ', '');
return null;
}
}
Thanks,
Victor
Hi,
I have a PDF fiel (Whitepaper) and I want to create a Visualforce page so when a user click a button, they can see/download the PDF file.
Can you help me with the codes (VFP 7 controller)? thanks

Let consider an object has 10 fields and one more field called CountField. If I enter a value for field1 and if i save it, Then the CountField value should be updated with 1. Same like that if I enter value for field1 and field2, Then the CountField field value should be updated with 2. Even if i enter a values for field1, field3, field9 and field5, then the CountField should be updated with 4 . Like that i enter values for all fields, then countfield vlaue should be 10. Which means how many fields i entered values, the same value should be updated with CountField.
I have tried alot. but i could not get any logic. Please provide some solution

User-added imageUser-added image
Note: The value for countfield in image is entered by me manually. I want it automatically updated.

Thanks 
KS Kumar

Hi,
I have a controller on my visualforce page and I am not able to build test data to cover for the coverage for the below variables. The data comes in from my visualforce page. Can someone please advise?

public class OppExtension{
    public OppExtension(ApexPages.StandardController controller) {
        std = controller;
        OpptyRec = (Opportunity)std.getRecord();
}

public string s1{get;set;}
    public string s2{get;set;}
    public string s3{get;set;}

public PageReference assignvalue(){
        s1 = s1.replace('North America (%) : ', '');
        s2 = s2.replace('APAC (%) : ', '');
        s3 = s3.replace('LATAM (%)  : ', '');
return null;
}
}
Thanks,
Victor
Hi Folks,

I wanted to query metadata components( Fields, Objects, Validation Rules, Workflow Rules, Approval Process..etc) by using SOQL query in Apex. So, Could you please anyone check let me know do we have any workaround for this.

i'm just curious about whether is it possible by using Query or not.

Thanks,
Anil
hai all 
i need a write dynamically add a pagelayouts to the profile through apex code using vfpage also
how can i do that
hii..
I have a button on the click of button output show in same tab , I want on the click of button output display a new tab without using java script?
plz help me...
 
=============It's my visualforce page code :- =============

<apex:page standardController="Opportunity" extensions="quickaction">
<apex:form >
<style>
.test{

float:right;

}
</style>

<div class='test'>
<apex:commandButton action="{!call}"  image="/resource/trac_QuickActions/Phone.png"/>
<apex:commandButton action="{!email}" image="/resource/trac_QuickActions/Mail.png"/>
<apex:commandButton action="{!meeting}" image="/resource/trac_QuickActions/Calendar.png"/>
<apex:commandButton action="{!task}" image="/resource/trac_QuickActions/Notes.png"/>
</div>
</apex:form>
</apex:page>

=========It's my apex code:-==========

public class quickaction {

    public String p;
    public String Name1;
    public quickaction(ApexPages.StandardController controller) {
 
 p = ApexPages.currentPage().getParameters().get('id');
 
 integer n=[SELECT Count() FROM OpportunityContactRole WHERE OpportunityId =:ApexPages.currentPage().getParameters().get('id') AND IsPrimary = true];
 system.debug(Name1+'nnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnn');
 
 if(n > 0){
 
 OpportunityContactRole op=[SELECT ContactId FROM OpportunityContactRole WHERE OpportunityId =:ApexPages.currentPage().getParameters().get('id') AND IsPrimary = true];
 
 Contact c=[select Name,id From Contact where Id=:op.ContactId ];
 
 Name1=c.Name;
 
 system.debug(Name1+'nnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnn');
 
 }
 
 
 
    }

public PageReference task(){

 PageReference acctPage = new PageReference('/00T/e?who_id='+userinfo.getuserid()+'&what_id='+ApexPages.currentPage().getParameters().get('id')+'&tsk4='+system.today().month()+'/'+system.today().day()+'/'+system.today().year()+'&retURL='+ApexPages.currentPage().getParameters().get('id'));
        acctPage.setRedirect(true);
        return acctPage;

}

public PageReference email(){
if(Name1 != null){
 PageReference acctPage = new PageReference('/00T/e?title=Call&who_id='+userinfo.getuserid()+'&what_id='+ApexPages.currentPage().getParameters().get('id')+'&00N7A000000NoRh=Communication&tsk5=Email&00N7A000000NoRm=Email&tsk4='+system.today().month()+'/'+system.today().day()+'/'+system.today().year()+'&tsk12=Completed&tsk2='+Name1+'&retURL='+ApexPages.currentPage().getParameters().get('id'));
        acctPage.setRedirect(true);
        return acctPage;
        }
        else{
         PageReference acctPage = new PageReference('/00T/e?title=Call&who_id='+userinfo.getuserid()+'&what_id='+ApexPages.currentPage().getParameters().get('id')+'&00N7A000000NoRh=Communication&tsk5=Email&00N7A000000NoRm=Email&retURL='+ApexPages.currentPage().getParameters().get('id'));
        acctPage.setRedirect(true);
        return acctPage;
        
        
        }
}
public PageReference call(){
if(Name1 != ''){
 PageReference acctPage = new PageReference('/00T/e?title=Call&who_id='+userinfo.getuserid()+'&what_id='+ApexPages.currentPage().getParameters().get('id')+'&00N7A000000NoRh=Communication&tsk5=Call&00N7A000000NoRm=Call&tsk4='+system.today().month()+'/'+system.today().day()+'/'+system.today().year()+'&tsk12=Completed&tsk2='+Name1+'&retURL='+ApexPages.currentPage().getParameters().get('id'));
        acctPage.setRedirect(true);
        
        return acctPage ;
}
else{

 PageReference acctPage = new PageReference('/00T/e?title=Call&who_id='+userinfo.getuserid()+'&what_id='+ApexPages.currentPage().getParameters().get('id')+'&00N7A000000NoRh=Communication&tsk5=Call&00N7A000000NoRm=Call&retURL='+ApexPages.currentPage().getParameters().get('id'));
        acctPage.setRedirect(true);
     
        return acctPage ;




}
}
public PageReference meeting(){
if(Name1 != null){
 PageReference acctPage = new PageReference('/00U/e?who_id='+userinfo.getuserid()+'&what_id='+ApexPages.currentPage().getParameters().get('id')+'&ent=Event&retURL= '+ApexPages.currentPage().getParameters().get('id')+'&evt5=Meeting Booked with '+Name1+'&evt4='+system.today().month()+'/'+system.today().day()+'/'+system.today().year()+'&evt2='+Name1);

        acctPage.setRedirect(true);
        return acctPage;
}
else{

 PageReference acctPage = new PageReference('/00U/e?who_id='+userinfo.getuserid()+'&what_id='+ApexPages.currentPage().getParameters().get('id')+'&ent=Event&retURL= '+ApexPages.currentPage().getParameters().get('id')+'&evt5=Meeting&evt4='+system.today().month()+'/'+system.today().day()+'/'+system.today().year());

        acctPage.setRedirect(true);
        
        return acctPage;


}

}
}
Hi,
I have a PDF fiel (Whitepaper) and I want to create a Visualforce page so when a user click a button, they can see/download the PDF file.
Can you help me with the codes (VFP 7 controller)? thanks

Let consider an object has 10 fields and one more field called CountField. If I enter a value for field1 and if i save it, Then the CountField value should be updated with 1. Same like that if I enter value for field1 and field2, Then the CountField field value should be updated with 2. Even if i enter a values for field1, field3, field9 and field5, then the CountField should be updated with 4 . Like that i enter values for all fields, then countfield vlaue should be 10. Which means how many fields i entered values, the same value should be updated with CountField.
I have tried alot. but i could not get any logic. Please provide some solution

User-added imageUser-added image
Note: The value for countfield in image is entered by me manually. I want it automatically updated.

Thanks 
KS Kumar

Go to the last module of Admin Traol for beginner , which is Formulae validations and select the first module "Using Formula Fields". The Menu language changes to French from English!

Posting this in order to help others who, months from now, might Google "OP_WITH_INVALID_USER_TYPE_EXCEPTION" and find this explanation.

 

We wrote an Apex trigger on the User object, to insert a custom object record anytime a user updates their Chatter status.  This was done to fulfill a client's requirement to audit all Chatter activity.

 

The trigger worked fine, until one day the client signed up some Chatter Free users.  When such a user tried to update their status, they got a pop-up with an OP_WITH_INVALID_USER_TYPE_EXCEPTION error.

 

We scratched our collective heads for awhile.  After all, Apex triggers run in "system mode," right?  That is supposed to mean that "object and field-level permissions of the current user are ignored."  And yet this trigger seemed like it was running in "user mode," enforcing restrictions based on who the current user was.

 

The root cause turned out to be that a Chatter Free user cannot be the owner of a custom object record, and SFDC by default sets the current user as a new record's first owner.  We discovered this when we realized, via experiment, that Apex triggers fired as the result of actions by Chatter Free users could definitely update an existing record, but were having problems creating records.

 

So the simple solution was to explicitly set the owner of the new record to some fully-licensed user prior to inserting it.