• PS81
  • NEWBIE
  • 140 Points
  • Member since 2015

  • Chatter
    Feed
  • 0
    Best Answers
  • 2
    Likes Received
  • 0
    Likes Given
  • 48
    Questions
  • 65
    Replies
When a user clicks on other opportunities of different department i see 'Insufficient Privilege' error shown on the screen but not observed for custom VF page.

How can i force the same functionality or error msg shown for the custom page? any advise please?


the same profile is used across different roles and hence Manager 1 can access all of his subordinates opportunities and same applies to manager 2. Subordinate of manager 2 shouldn't access subordinate's opportunity under manager 1. here all have access to the same custom VF page.
  • January 07, 2016
  • Like
  • 0
Hi

I have a textarea which i'm trying to disable using the below code via JQuery read function
jQuery( document ).ready( function(){
jQuery( 'input[id$=oprm12]' ).prop('disabled', true);   //Works for text field
jQuery( 'input[id$=oprprob]' ).prop('disabled', true);  //Does not works for text area
 }


The function works for text field but not for textarea field. the id 'oprprob' refers to an input field of type textarea in opportunity. Any inputs on how to fix this please?
  • December 08, 2015
  • Like
  • 0
Hello

I have a standard controller overriding the 'edit page' for opportunity. Need some help to write a test class to do a code coverage for this standard contlr please?

my overridding page :
 
<apex:page standardController="Opportunity" tabStyle="Opportunity" extensions="OpportunitySave" >
		<apex:sectionHeader title="Opportunity Edit" subtitle="{!Opportunity.name}"/>
		….
		….
		….
		<body>
		    <apex:pageBlock title="Opportunity Edit" mode="edit"  >
		        <apex:pageBlockButtons >
		            <apex:commandButton action="{!save}" value="Save" />
		            <apex:commandButton action="{!Cancel}" value="Cancel"/>
		        </apex:pageBlockButtons>
		        <apex:pageblocksection id="OprInfo" title="Opportunity Information" columns="2">
		            <apex:inputfield value="{!Opportunity.name}" id="oprname"/> 
		            <apex:inputfield value="{!Opportunity.AccountId}" id="opraccname" required="true"/> 
		….
		….
		….

and the class :
 
public with sharing class OpportunitySave {
		    public string probs {set;get;}
		    public boolean disable{set;get;}
		    public Opportunity opr {get;set;}
		    private ApexPages.StandardController stdCtrl;
		    public OpportunitySave(ApexPages.StandardController controller) {
		        stdCtrl = controller;
		        opr = (Opportunity)controller.getRecord();
		        disable = false;
		    }
		    public PageReference setpresales(){
		        if (opr.Type == 'Big Ticket')
		            opr.Presales__c = 'Yes';
		        else
		            opr.Presales__c = 'No';
		        return null;
		    }
		    public PageReference setProbability(){
		        }
		        return null;
		    }


 
  • November 23, 2015
  • Like
  • 0
I've created a trigger that calls the metadata api (class created from metadata api wsdl) for updating the picklist value in a sobject. Now with this working fine i need to deploy it for which the code coverage is required.

I wrote the below piece of code to test:
 
static testmethod void UpdateSalesOwnerPicklist_Tr(){
		        user usr =  new user();
		        usr.LastName = 'Phil';
		        usr.Alias = 'Sphil';
		        usr.Email = 'non@none.co.uk';
		        usr.Username = 'spencer.phil@capita.co.uk';
		        usr.CommunityNickname = 'Phil';
		        usr.TimeZoneSidKey = 'Europe/London';
		        usr.LocaleSidKey = 'en_GB';
		        usr.EmailEncodingKey = 'ISO-8859-1';
		        usr.ProfileId = '00e2400000103uxAAA';
		        usr.LanguageLocaleKey = 'en_US';
		        //insert user
		        insert usr;
		    }
but for the error Methods defined as TestMethod do not support Web service callouts

Following this i did refer the link  https://developer.salesforce.com/docs/atlas.en-us.apexcode.meta/apexcode/apex_callouts_wsdl2apex_testing.htm    but quite confused on how to approach the test class? any help on this please?
 
  • November 19, 2015
  • Like
  • 0
Hi

I'm pretty much new to salesforce. As my first task i had written a trigger but need help to write a test case or test class. Please any help on this?
 
trigger OpportunityWeightageRev on Opportunity (before update) {
    double prob_diff = 0;
    double Nrev = 0; //New revenue
    double Orev = 0; //Old revenue
    
    Opportunity OprLast; //Previous opportunity data
    for(Opportunity Opr : Trigger.new){
        OprLast = Trigger.oldMap.get(Opr.id); 
        if(OprLast.Probability != opr.Probability){
            if(prob_diff==0){
                prob_diff = math.abs(OprLast.Probability - opr.Probability);
            }
            if((opr.Total_Contract_Value__c==0) || (opr.Total_Contract_Value__c==null)) opr.Total_Contract_Value__c = 0;
            nrev = opr.Total_Contract_Value__c * (prob_diff/100);
            orev = OprLast.Weighted_Revenue__c;
            
            if(orev<>0){
                opr.mplan__c 		=  nrev / orev;

            }
        }            
    }
}

 
  • November 18, 2015
  • Like
  • 0
Hi

We are gonna to move set of developments to production org but now have a question with regards to deployment. I read in one of the doc that we cant deploy the code in prod org if the code test coverage is atleast 75%. I must say that i have not written test coverage code...so the question is :
1. how to do the test coverage code?
2. For instance i have a class called myClass and should I create a new class called myclasstest for test coverage? if yes how would the new class would know that the test case is for the intended class ?
  • November 18, 2015
  • Like
  • 0
Hi

i'm using email templates to receive mail but seems the format is not the same as in template when the mail is recievied:
 
<messaging:emailTemplate subject="Your campaign {!relatedTo.Name} is due to start" recipientType="User" relatedToType="Campaign">
<messaging:htmlEmailBody >
    <html>
        <head>
        <style>
        #header {
            position: relative;
            background-color:white;
            left: 100px;
            width:60%;
            float:left;
            margin-bottom:5px;
            padding:5px; 
        }
        #body {
            position: relative;
            left: 100px;
            background-color:white;
            height:250px;
            width:60%;
            float:left;
            padding:5px;          
        }
        </style>
        </head>
        <body bgcolor="#00A1C1">
            <div>
                <div id ="header">
                    <img src="NEC_Logo" alt="logo"></img>
                </div>
                <div id ="body">
                Dear {!recipient.name}
                
                <br></br> 
                <br>
                    Notification that "{!relatedTo.Name}" is due to start today.
                </br>
                </div>
             </div>
        </body>
    </html>
</messaging:htmlEmailBody>
</messaging:emailTemplate>

Any input on how to make it consistent with the template please?
  • November 16, 2015
  • Like
  • 0
Hi

I have updated a logo into the document folder and referencing with the below set of code in the visualforce template:
 
<body bgcolor="#00A1C1">
        <div>
        <div id ="header">
        <img src="NEC_Logo"></img>
        </div>
        <div id ="body">
         Dear {!recipient.name}
        
         <br></br> 
         <br>
             Notification that "{!relatedTo.Name}" is due to start today.
         </br>
         </div>
         </div>
        </body>
    </html>
</messaging:htmlEmailBody>
</messaging:emailTemplate>

But when i save and view in preview i see as below:

Logo not seen

Not clear enough on what is the issue. any inputs on this please?
  • November 16, 2015
  • Like
  • 0
Hi

I have created a simple visualforce email template to be used in my apex class (note the email to be triggered from apex and not via any user action via vf page).
 
<messaging:emailTemplate subject="<i>Your campaign {!relatedTo.Name} is due to start.</i>" recipientType="user" relatedToType="Campaign">
<messaging:htmlEmailBody >
<html>
    Dear {!recipient.name}<br></br>
    <br>
    Notification that "{!relatedTo.Name}" is due to start today. 
    </br>
</html>
</messaging:htmlEmailBody>
</messaging:emailTemplate>

But when i wanted to test it via the "Send Test and Verify Merge Fields" i do not get to see any selection but rather a message 

The template does not have a controller that can be selected for preview.

Any input on where i'm going wrong and what needs to be done here please?


 
  • November 16, 2015
  • Like
  • 0
Hi

My requirement is quite stranges from the user's end. While assigning a product line to opportunity we calculate the number of project days and assign the availability across 12 custom fields representing the twelve months. But if a product's end date is beyond two years we need to have a facility for the user to enter the allocation for 12 months across each year in 2016, 2017 etc which seems quite dynamic as we move to next financial year. 

How can i accomodate such a requirement?

My thoughts was to have a push button enabled for each prouct line (in a new vf page) when the end date is beyond 365 days so that on the click of the button a new page will be displayed with table like strucutre for number of years depending on the end date of the product i.e. 2 tables  with 12 cells each for 2016 , 2017 etc....If this sounds programable I'm quite confused on how i can store this data in sobject? Unless until the product entry i donot know the number of years for the product, in such case how to go with it?

any suggestion on this please?
  • November 05, 2015
  • Like
  • 0
I had retrieved the list of user names that is to be updated via metadata api to the custom picklist in the sobj 'contact'. Question is how do i update the picklist values in the loop?
 
MetadataAPIService.MetadataPort service = createService();
    service.SessionHeader.sessionId = sessionId;
    MetadataAPIService.CustomField customField = new MetadataAPIService.CustomField();
    customField.fullName = 'Contact.Test__c'; 
    customField.label = 'Test';
    customField.type_x = 'Picklist'; //customField.type = 'Picklist';
    metadataAPIservice.Picklist sown = new metadataAPIservice.Picklist();
    sown.sorted= false;
    metadataAPIservice.PicklistValue pval = new metadataAPIservice.PicklistValue();
    pval.fullName= 'SHP Picked';
    pval.default_x=false ;
    // Get the user list
    list<user> users = getUserList();
    for (User usr:users){
        //what to do in to insert the list into picklistValues?
    }
    sown.picklistValues = new List<MetadataAPIService.PicklistValue>{pval};

 
  • November 03, 2015
  • Like
  • 0
Hi

How to access MetadataService.cls and use it? I want to modify the picklist values and reading couple of post I could understand that using MetadataService.cls i can achieve it but i dont know where to get this MetadataService.cls and how to access it ....an tips please?
  • October 28, 2015
  • Like
  • 0
Please may i ask for tips on how to enable a picklist of standard object or a custom field in standard object with dynamic picklist value? I want the values to be referenced to users object for specific profiles/roles only....

I'm aware we can create field dependency as lookup but giving it in picklist is waht the users are looking for and i dont wish to create a VF page overriding the standard.
  • October 28, 2015
  • Like
  • 0
Hi

In Opportunity, I wish to create a custom field like 'StageName' having a similiar function and layout as in the screenshot:

User-added image

1. How can create such field? 
2. If this is not possible I've a question why such different layout/function for this field alone (StageName) ?
  • October 22, 2015
  • Like
  • 0
I need help on setting the field dependencies on VF page (copy of standard opportunity page)

Below is the opportunity screen and the field-dependencies are enabled for Probability - depedendant on stage , Presales - dependant on Type etc
User-added image
with standard the field dependencies work fine but in the custom VF page which is the copy of the standard it doesnt work fine....as in standard eventhough the mandatory fields are not filled if i click on 'Stage' the 'Probability' field is set accordingly but in custom page it doesnt happen and i need to fill in mandatory fields for the field dependency to work...

any help to correct this please?
  • October 22, 2015
  • Like
  • 1
Hi

I've created an opportunity but unable to edit it and get the below error:

Insufficient Privileges
You do not have the level of access necessary to perform the operation you requested. Please contact the owner of the record or your administrator if access is necessary. For more information, see Insufficient Privileges Errors. 


unsure what went wrong with the authorization security etc....any input to fix this please?
  • October 21, 2015
  • Like
  • 0
Hi

I have a picklist in my VF page and have set an event.....based on the value that is picked i need to set a percentage field with some value which i think is not happeing....i'm sure there is something i'm missing and need help to fix it please?

my vf code:

            <apex:inputfield value="{!Opportunity.StageName}" >
                <apex:actionSupport id="oprstage" event="onchange" action="{!setProbability}" rerender="productInfo" immediate="TRUE" />
            </apex:inputfield>
            <apex:inputfield value="{!Opportunity.Day_Rate__c}" id="oprrate"/>
            <apex:inputfield value="{!opr.Probability}" id="oprprob"/>

controller:

public with sharing class OpportunitySave {
    public string probability {get;set;}
    public Opportunity opr {get;set;}
    public OpportunitySave(ApexPages.StandardController controller) {

    }
    public PageReference setProbability(){
        opr.Probability = '30%';
        return null;
    }
}
  • October 21, 2015
  • Like
  • 0
I have created a custom lookup field in contacts referring to the object USERS and added this to the layout. When i create a new contact i can view the new lookup field but when i click on the magnifying glass to select a user i donot see any listed by default. If i type as A* in search field and search the system list the users matching the criteria but my question is how to list a specific list of users based on role by default ?

If this is  a std behaviour  would i be able to have a custom VF page for the lookup field i added? if so how can i achieve it?
  • October 20, 2015
  • Like
  • 0
Hi

I have a lookup field declared as below:

<apex:inputfield value="{!Product2.Opportunity__c}" id="prodoppr"/>

wish to know how to add or handle event for this lookup field? When there is a change in the value I want to trigger method to perform certain validation and upate other fields....how can i achieve this? please any inputs?
  • October 19, 2015
  • Like
  • 0
I had created a new VF page as like the page for editing the products which seems to work fine. I have a button 'Save' and 'Cancel' for which i have the action for the buttons as action="{!save}" and action="{!cancel}". though i do not have any codes at the controller for save and cancel the page is pretty much doing its job. so the question is:

does the action for save and cancel i have as below are standard actions for save and cancel?

<apex:commandButton action="{!save}" value="Save" /> <apex:commandButton action="{!Cancel}" value="Cancel"/>

in standard When creating a new product i see another button 'Save & Add price' which takes me to a subsequent screen to add the price. How can i get the action for 'Save & Add price' button so that i can use it in my controller in way from my custom VF page I can do the add price page directly?
  • October 15, 2015
  • Like
  • 0
I need help on setting the field dependencies on VF page (copy of standard opportunity page)

Below is the opportunity screen and the field-dependencies are enabled for Probability - depedendant on stage , Presales - dependant on Type etc
User-added image
with standard the field dependencies work fine but in the custom VF page which is the copy of the standard it doesnt work fine....as in standard eventhough the mandatory fields are not filled if i click on 'Stage' the 'Probability' field is set accordingly but in custom page it doesnt happen and i need to fill in mandatory fields for the field dependency to work...

any help to correct this please?
  • October 22, 2015
  • Like
  • 1
Hi

I've been reading on properties in apex but still bit confused on the actual use case of it. please can anyone help me to understand it?
  • October 05, 2015
  • Like
  • 1
Hi

I have a textarea which i'm trying to disable using the below code via JQuery read function
jQuery( document ).ready( function(){
jQuery( 'input[id$=oprm12]' ).prop('disabled', true);   //Works for text field
jQuery( 'input[id$=oprprob]' ).prop('disabled', true);  //Does not works for text area
 }


The function works for text field but not for textarea field. the id 'oprprob' refers to an input field of type textarea in opportunity. Any inputs on how to fix this please?
  • December 08, 2015
  • Like
  • 0
I've created a trigger that calls the metadata api (class created from metadata api wsdl) for updating the picklist value in a sobject. Now with this working fine i need to deploy it for which the code coverage is required.

I wrote the below piece of code to test:
 
static testmethod void UpdateSalesOwnerPicklist_Tr(){
		        user usr =  new user();
		        usr.LastName = 'Phil';
		        usr.Alias = 'Sphil';
		        usr.Email = 'non@none.co.uk';
		        usr.Username = 'spencer.phil@capita.co.uk';
		        usr.CommunityNickname = 'Phil';
		        usr.TimeZoneSidKey = 'Europe/London';
		        usr.LocaleSidKey = 'en_GB';
		        usr.EmailEncodingKey = 'ISO-8859-1';
		        usr.ProfileId = '00e2400000103uxAAA';
		        usr.LanguageLocaleKey = 'en_US';
		        //insert user
		        insert usr;
		    }
but for the error Methods defined as TestMethod do not support Web service callouts

Following this i did refer the link  https://developer.salesforce.com/docs/atlas.en-us.apexcode.meta/apexcode/apex_callouts_wsdl2apex_testing.htm    but quite confused on how to approach the test class? any help on this please?
 
  • November 19, 2015
  • Like
  • 0
Hi

I'm pretty much new to salesforce. As my first task i had written a trigger but need help to write a test case or test class. Please any help on this?
 
trigger OpportunityWeightageRev on Opportunity (before update) {
    double prob_diff = 0;
    double Nrev = 0; //New revenue
    double Orev = 0; //Old revenue
    
    Opportunity OprLast; //Previous opportunity data
    for(Opportunity Opr : Trigger.new){
        OprLast = Trigger.oldMap.get(Opr.id); 
        if(OprLast.Probability != opr.Probability){
            if(prob_diff==0){
                prob_diff = math.abs(OprLast.Probability - opr.Probability);
            }
            if((opr.Total_Contract_Value__c==0) || (opr.Total_Contract_Value__c==null)) opr.Total_Contract_Value__c = 0;
            nrev = opr.Total_Contract_Value__c * (prob_diff/100);
            orev = OprLast.Weighted_Revenue__c;
            
            if(orev<>0){
                opr.mplan__c 		=  nrev / orev;

            }
        }            
    }
}

 
  • November 18, 2015
  • Like
  • 0
Hi

We are gonna to move set of developments to production org but now have a question with regards to deployment. I read in one of the doc that we cant deploy the code in prod org if the code test coverage is atleast 75%. I must say that i have not written test coverage code...so the question is :
1. how to do the test coverage code?
2. For instance i have a class called myClass and should I create a new class called myclasstest for test coverage? if yes how would the new class would know that the test case is for the intended class ?
  • November 18, 2015
  • Like
  • 0
Hi

I have created a simple visualforce email template to be used in my apex class (note the email to be triggered from apex and not via any user action via vf page).
 
<messaging:emailTemplate subject="<i>Your campaign {!relatedTo.Name} is due to start.</i>" recipientType="user" relatedToType="Campaign">
<messaging:htmlEmailBody >
<html>
    Dear {!recipient.name}<br></br>
    <br>
    Notification that "{!relatedTo.Name}" is due to start today. 
    </br>
</html>
</messaging:htmlEmailBody>
</messaging:emailTemplate>

But when i wanted to test it via the "Send Test and Verify Merge Fields" i do not get to see any selection but rather a message 

The template does not have a controller that can be selected for preview.

Any input on where i'm going wrong and what needs to be done here please?


 
  • November 16, 2015
  • Like
  • 0
I had retrieved the list of user names that is to be updated via metadata api to the custom picklist in the sobj 'contact'. Question is how do i update the picklist values in the loop?
 
MetadataAPIService.MetadataPort service = createService();
    service.SessionHeader.sessionId = sessionId;
    MetadataAPIService.CustomField customField = new MetadataAPIService.CustomField();
    customField.fullName = 'Contact.Test__c'; 
    customField.label = 'Test';
    customField.type_x = 'Picklist'; //customField.type = 'Picklist';
    metadataAPIservice.Picklist sown = new metadataAPIservice.Picklist();
    sown.sorted= false;
    metadataAPIservice.PicklistValue pval = new metadataAPIservice.PicklistValue();
    pval.fullName= 'SHP Picked';
    pval.default_x=false ;
    // Get the user list
    list<user> users = getUserList();
    for (User usr:users){
        //what to do in to insert the list into picklistValues?
    }
    sown.picklistValues = new List<MetadataAPIService.PicklistValue>{pval};

 
  • November 03, 2015
  • Like
  • 0
Hi

How to access MetadataService.cls and use it? I want to modify the picklist values and reading couple of post I could understand that using MetadataService.cls i can achieve it but i dont know where to get this MetadataService.cls and how to access it ....an tips please?
  • October 28, 2015
  • Like
  • 0
Please may i ask for tips on how to enable a picklist of standard object or a custom field in standard object with dynamic picklist value? I want the values to be referenced to users object for specific profiles/roles only....

I'm aware we can create field dependency as lookup but giving it in picklist is waht the users are looking for and i dont wish to create a VF page overriding the standard.
  • October 28, 2015
  • Like
  • 0
Hi

I've created an opportunity but unable to edit it and get the below error:

Insufficient Privileges
You do not have the level of access necessary to perform the operation you requested. Please contact the owner of the record or your administrator if access is necessary. For more information, see Insufficient Privileges Errors. 


unsure what went wrong with the authorization security etc....any input to fix this please?
  • October 21, 2015
  • Like
  • 0
Hi

I have a picklist in my VF page and have set an event.....based on the value that is picked i need to set a percentage field with some value which i think is not happeing....i'm sure there is something i'm missing and need help to fix it please?

my vf code:

            <apex:inputfield value="{!Opportunity.StageName}" >
                <apex:actionSupport id="oprstage" event="onchange" action="{!setProbability}" rerender="productInfo" immediate="TRUE" />
            </apex:inputfield>
            <apex:inputfield value="{!Opportunity.Day_Rate__c}" id="oprrate"/>
            <apex:inputfield value="{!opr.Probability}" id="oprprob"/>

controller:

public with sharing class OpportunitySave {
    public string probability {get;set;}
    public Opportunity opr {get;set;}
    public OpportunitySave(ApexPages.StandardController controller) {

    }
    public PageReference setProbability(){
        opr.Probability = '30%';
        return null;
    }
}
  • October 21, 2015
  • Like
  • 0