• MellowRen
  • NEWBIE
  • 335 Points
  • Member since 2013

  • Chatter
    Feed
  • 11
    Best Answers
  • 1
    Likes Received
  • 1
    Likes Given
  • 17
    Questions
  • 95
    Replies
I only want the third word from the strings, I am stucked with the third formula , can anybody help me out...Here what I am trying : IF( NOT( ISBLANK(Name)) ,RIGHT( Name , ((LEN(Name) - FIND("", Name)) - FIND("",Name))  , MID(Name,Find(" ",Name,Find(" ",Name,1)+1)+1,Find(" ",Name,Find(" ",Name,Find(" ",Name,1)+1)+1)-(Find(" ",Name,Find(" ",Name,1)+1)+1)))
But not getting correct O/P ,when Name contains only three words. It work well when Name has four word in it.
Please help me out with the formula.
 
Hi my scenario is to restrict the user,if they try to edit the opportunity record after the three business days from the ClosedDate field. For example : if i update the opportunity after three days from the ClosedDate(5/12/2016), it will through an alart message, then if i edit the ClosedDate as 5/13/2016 then the record will save. But by requirement is to restrict the update operation itself. 
(CASE( 
MOD( CloseDate - DATE(1900, 1, 7), 7), 
0, CloseDate+3, 
1, CloseDate+3, 
2, CloseDate+3, 
3, CloseDate+5, 
4, CloseDate+5, 
5, CloseDate+5, 
6, CloseDate+4, 

CloseDate))<=TODAY()

 
I recently created a validation rule preventing all users not designated as "System Admin" from changing the stage of an opportunity to closed won or closed lost.  However, I see that the opportunity owner can still make changed regardless of this VR.  Is there anyway I can restric the record owner from making these changes so that the System Admins have exclusive access.  I have professional edition by the way.

And here is my VR 

AND( 
$UserRole.Name <> "System Admin", 
ISCHANGED(StageName), 
ISPICKVAL(StageName,"1 - Closed Won"), 
ISPICKVAL(StageName,"0 - Closed Lost"))

With below test class only 45% coverage is showing.can one provide suggetions to get 80%

Test Class

@isTest
public class AssignmentFourTest{
static testMethod void test(){
AssignmentFour vrb = new AssignmentFour ();
vrb.doSearch();
List<account> gacc = vrb.getAccounts();
account acc = new account(name='test account 32',BillingState = 'UK',Phone = '96589658',Website = 'abc@abc.com');
insert acc;
}
}

 

Controller class

public class AssignmentFour {
   //Declear Variables
   List<Account> accounts{get;set;}
   public String searchString { get; set; }

 public List<Account> getAccounts() {
      return accounts;
   } 
 //Logic to search the account and display in output panel in VF page
 public PageReference doSearch() {
      if(searchString !='' && searchString !=null){
         accounts = new list<account>();
         accounts = [Select Id,Name,BillingState,Phone,Website FROM Account where name =:searchString];
         //System.debug('@@@@@@@@@@searchString'+searchString);
      }
            if(accounts.size()>0 && accounts.size()!= null){
              // System.debug('@@@@@@listAccount.size()'+listAccount.size());
            }
            else{
                 ApexPages.addmessage(new ApexPages.message(ApexPages.severity.WARNING,'Please enter value'));
               }
       return NULL;
 }
}

Hi,

 

I wrote a Trigger to prevent the insertion of a new record whithin an SetUp__c  sObject if already exists ANY active records in there (the idea is that only one record should exist in that sObject). However the new record is inserted no matter what.

Here is the trigger code:

 

 

trigger NewSetUpRecord on SetUp__c (before insert) {

      List<SetUp__c> SUR = [SELECT Id, Name, IsDeleted FROM SetUp__c WHERE IsDeleted = false AND  id  IN :Trigger.new];

      boolean exists = false;

      if (SUR.size()>0) {

                      for (SetUp__c sr : SUR) {

                                 if (sr.IsDeleted) {}

                                 else {

                                   exists = true;

                                   break;

                                 }

                      }

                      if (!exists) {

                         insert SUR;

                      }

     }

}

 

Any ideas why this might be happening?

 

Thanks!

  • July 19, 2013
  • Like
  • 0

In my Workflow Rule:

Step 2: Configure Workflow Rule

              Rule Criteria: Run this rule if the following Formula evaluates to true:

 

ISPICKVAL(Referral__r.Referral_Status_n__c, “Create Opportunity”)

 

Error: Syntax error

 

Kindly help me to fix this

  • June 21, 2013
  • Like
  • 0

A few years ago we had someone create task templates and the trigger to create tasks on a custom object we call projects.  It worked well at the time, but I need to make it more flexible.  

 

Right now, it creates a task and assigns it to the Project Manager.  I'd like for it to look at a Task category (or something like it) field to determine what type of task it is and then assign it to the user assign to that role.  For example, we need to generate a task to the CAD Tech.  I'd like the trigger to look for the category: CAD and find the CAD Tech assigned (a lookup contact field on the project) to the project and assign the task to that person.  

 

Additionally, the current Task Template trigger makes the due date of the task = Start Date of the project.  I'd like it to be more flexible like tasks are if they're created by workflows: Trigger Date + 15, etc.  

 

Does anyone know how I could do that?

 

 

/*********************************************************************************
Name : createTasksForProjects 
Created Date : 7 Jan 2010
modified Date : 25 Jan 2010
Usages : If Create task is set to true 
         1)Then we need to fetch Task Templates having the region and project type.
         2)Create task for all the templates having same values for projects.
*********************************************************************************/
trigger createTasksForProjects on pse__Proj__c (After insert) {
   
    Set<String> projectRecordType = new Set<String>();
    Set<String> projectId = new Set<String>();
    List<pse__Proj__c> projectList = new List<pse__Proj__c>();
    //Create set of Region and Project Type.
    List<pse__proj__c> newProjectList = [Select Id ,Name ,CreateTask__c,RecordTypeId,RecordType.Name,pse__Project_Manager__c,CAD_Tech__c,Programmer__c,Lead_Tech__c,CAD_Hours__c,pse__Start_Date__c from pse__proj__c where id in: Trigger.New];
    For(pse__Proj__c proj : newProjectList){
       if(proj.CreateTask__c == true){
         System.Debug('Record Type :'+proj.RecordTypeId);
         if(proj.RecordTypeId!=null){
            System.Debug('Record Type Name:'+proj.RecordType.Name);
            projectRecordType.add(proj.RecordType.Name);
         }
       }
    }
    List<Task> tasksToCreate = new List<Task>();
    //If region and project type exists.
    if(projectRecordType.size() > 0){
        
        //Fetch all task templates which holds same region and Project Type.
        For(List<Task_Template__c> taskTemplates : [Select id,Order__c,Project_Type__c,Assigned__c,Region_del__c,Subject__c,Name,Project_Record_Type__c From  Task_Template__c Where Project_Record_Type__c in : projectRecordType ]){
            For(Task_Template__c taskTemp : taskTemplates ){
                For(pse__Proj__c proj :newProjectList){
                    System.Debug('project Record Type '+proj.RecordType.Name+'\n Template project type'+taskTemp.Project_Record_Type__c);
                   //Create Task.
                   if(proj.RecordTypeId!=null && proj.RecordType.Name == taskTemp.Project_Record_Type__c){
                        if(proj.CreateTask__c == true && proj.pse__Project_Manager__c != null){
                            Task task = new Task();
                            task.Subject = taskTemp.name; 
                            task.WhoID = proj.pse__Project_Manager__c;                  
                            task.ActivityDate = proj.pse__Start_Date__c;
                            task.WhatID = proj.id;
                            task.Order__c = taskTemp.Order__c;
                            task.type = 'Other';
                            tasksToCreate.Add(task);
                            //If size more then 998 then need to insert list and clear it as it can hold only 1000 records.
                            if(tasksToCreate.size()== 999){
                                insert tasksToCreate;
                                tasksToCreate.clear();
                            }
                            projectId.add(proj.Id);                             
                        }
                    }
                }
            }            
        }
        //If size greater then 0 then insert task.
        if(tasksToCreate.size()> 0){
            insert tasksToCreate;
        }
        for(pse__Proj__c proj:Trigger.New){
            if(projectId.contains(proj.Id)){
                pse__Proj__c projObj = new pse__Proj__c(Id=proj.Id);
                projObj.alreadyCreateTaskFlag__c = true;
                projectList.add(projObj);
                if(projectList.size()== 999){
                       update projectList;
                       projectList.clear();
                }
            }
        }
        if(projectList.size()>0){
            update projectList;
        }
    }

}

Current fields on the Task Template object are:

Field Label                       API Name                             Data Type

Assigned                         Assigned__c                        Lookup(User)

Order                                Order__c                               Number(3, 0)

Project Record Type     Project_Record_Type__c   Picklist

Project Type                    Project_Type__c                  Picklist

Region                             Region_del__c                    Lookup(Region)

Subject                            Subject__c                            Text(100)

 

Thanks!

Mander

Hi

 

I am trying to create formula to calculate discount  ((ListPrice - UnitPrice ) / ListPrice) * 100 on quote line item.

I can see ListPrice read only field is there on quote line item still I am getting error ListPrice field does not exist.

 

Or

Is there any waty I can bring discount amount from opportunity line item.

 

Thanks,

Hello All,


I am new at this, I am trying to customize so that I can calcucate a percentage of late fee based on days past due and bal of invoice.

I keep getting syntax errors.  Any suggestions?

 

 

 

IF(AND(forseva1__FInvoice__c.forseva1__Days_Past_Due__c >0,forseva1__FInvoice__c.Gross_Invoice_Total__c >= 2000), ROUND(forseva1__FInvoice__c.forseva1__Days_Past_Due__c *0 .00493) , 2)
((forseva1__FInvoice__c.forseva1__Days_Past_Due__c * 0.000164))

Please help! I'm new at this. I'm trying to calculate the number of days served in the year. My data fields are date/time but I'm only wanting to calculate the days. I have some that came in the previous year (2011) but I only want to count the days in 2012. I have others that came in 2012 and are still there so I only want to count them through 12/31/2012.There is a total of 4 possibilities.  Here is the formula that I have created but I keep getting Syntax errors. I'm trying to say if the Date Time In and Out fit the criteria then calculate it this way.

 

IF (DAY_ONLY() Date_Time_In__c < 2012-01-01 and Date_Time_Out__c <2012-12-31,  Date_Time_Out__c  -  2012-01-01  + 1,
(DAY_ONLY() Date_Time_In__c > 2012-01-01 and Date_Time_Out__c <2012-12-31, Date_Time_Out__c   - Date_Time_In__c  + 1,
(DAY_ONLY() Date_Time_In__c < 2012-01-01 and Date_Time_Out__c ISBLANK, 2012-12-31  2 - 012-01-01 + 1,
(DAY_ONLY() Date_Time_In__c > 2012-01-01 and Date_Time_Out__c ISBLANK, 2012-12-31  - Date_Time_In__c
))))

 

Is there an easier way to do this?

 

Thanks so much in advance for your help.

Hi

I am putting together a system and something is going awefully wrong. May be I am too tired but I simply can't understand what is going on.

I have two Objects "Prod" and "Prod Detail" in a Master/Detail relationship. I have a Visualforce page "ProdEdit" for Prod with an extension. I want the page to have a button that takes a User (supplied) and adds a Prod Detail record. I have done similar tings to this before but this is not working. I have copied over a reduced set of code to my developer account and get the same behaviour.

The Page:
Hi
 
I am putting together a system and something is going awfully wrong. May be I am too tired but I simply can't understand what is going on.
 
I have two Objects "Prod" and "Prod Detail" in a Master/Detail relationship. I have a Visualforce page "ProdEdit" for Prod with an extension. I want the page to have a button that takes a User (supplied) and adds a Prod Detail record. I have done similar tings to this before but this is not working. I have copied over a reduced set of code to my developer account and get the same behavior.
<apex:page standardcontroller="Prod__c" extensions="Prod_Edit_Ext">
    <!-- The page -->
    <apex:form id="thePage">
        
    	<!-- In View Mode: Has Options Lists. -->
        	<apex:pageBlock title="Prod Detail" mode="maindetail">
                <apex:pageBlockSection title="Information" columns="2">
                    <apex:outputField value="{!Prod__c.Name}"/>
                    <apex:outputField value="{!Prod__c.Manufacturer__c}"/>
                    <apex:outputField value="{!Prod__c.OwnerId}" label="Prod Manager"/>
                </apex:pageBlockSection>
                <br/><br/>
            </apex:pageBlock>
         	<apex:pageBlock mode="edit">
                <apex:pageBlockSection columns="2" id="newPD">
                    <apex:inputField label="New Manager" value="{!newProdDetailWithUser.User__c}"/>
                    <apex:commandButton value="Add Prod Detail" action="{!addProdDetail}" immediate="true"/>
                </apex:pageBlockSection>
        </apex:pageBlock>                        
    </apex:form>
</apex:page>

The Extension
public class Prod_Edit_Ext {
    //Variables
    private ApexPages.StandardController stdProdCtrl; //for a link to the Controller class (that this is extending) so as to use its methods.
    private Prod__c  theProd;
        
    //Getters & Setters (Simple)
    public Prod_Detail__c newProdDetailWithUser {get; set;}
    
	//Constructor
    public Prod_Edit_Ext(ApexPages.StandardController controller) {
System.debug('zzz In Constructor');
        stdProdCtrl = controller;
        theProd = (Prod__c) stdProdCtrl.getRecord(); //use std controller to get record.

        //Initialise Prod Details
        newProdDetailWithUser = new Prod_Detail__c();
    }
    
    //Action Methods
    public void addProdDetail() {
        // This function runs when a user hits "add" button.
System.debug('zzz Start Add: '+newProdDetailWithUser);
       // if (newProdDetailWithUser.User__c != null) {
            newProdDetailWithUser.Prod__c = theProd.Id;
            newProdDetailWithUser.Name = 'Test: '+Datetime.now().format();
System.debug('zzz Ready to insert: '+newProdDetailWithUser);
System.debug('zzz User to insert: '+newProdDetailWithUser.User__c);
            INSERT newProdDetailWithUser;
System.debug('zzz Inserted: '+newProdDetailWithUser);
      //  }
        newProdDetailWithUser = new Prod_Detail__c();
    }
}

This is creating bizarre results:
  1. When I first load the page, a record is created even though the button is not yet pushed.
  2. After I select a User in the field, and press the button, a Prod Detail record is created but only with the Name (and the Prod link) but not with the User I just selected. That field is left blank. The debug statements show it is null before the Insert.
I am going stir-crazy. I have experimented with page block modes, full on getters and setters, etc but cannot get it to work. Would really appreciate if someone was able to tell me what I have done wrong.

Regards
MellowRen
Hi

I am hopeless with the whole Schema and getDescribe thing. Is this possible? Can anyone point me in the right direction?

I am trying to build a generic method that if passed a List of SObject (type unknown when passed) will return (ideally) a Map of the Record Type Names.

public Map<ID, String> getRecordTypeNames(List<SObject> theSObjects) {

Salesforce documentation suggests that a getDescribe is the best practice method but at this point I’d be happy enough with an SOQL based solution as well. My hangup is that in both cases I need to know what type of object (Account, Opportunity, etc) each record is before I can get the record type but to do that I will end up with a non-bulkified solution (I think).

I am really hoping I am missing something obvious here. Google and forum searching appear to be failing me though :-(

Any advice?

Regards
MellowRen

Hi

 

In most chart related tags there is an attribute called rendererFn which is usually defined in the docs as “A string that specifies the name of a JavaScript function that augments or overrides how each data point is rendered. Implement to provide additional styling or to augment data.”

 

Well that’s nice. May be I am looking in the wrong place (or using the wrong search terms) but I can’t seem to find any documentation on the format required for these functions. There is one repeated code example that someone wrote (I think this is the original source, apologies to the author if not).

 

The thing I find fascinating is that in the Visualforce tag the attribute is written as rendererFn="renderer" yet the function definition has two parameters function renderer(klass, item).

 

I have tested this code and it fully works so the author is correct. Does anyone know where I can get the definition of klass and item and how to interact with them? Or can anyone with better Javascript knowledge make an educated guess? “item” allows you do access the data record values (e.g. var type = item.storeItem.get('ctype'); ). I have no idea how that works but it does and it is easy enough to modify for my own data structures. What other information can be pulled out of these variables?

 

My main goal is to be able to get more information about what item is being hovered over (actually clicked but regardless same problem). For instance, my chart has multiple lineSeries tags. I am wondering if through klass or item I can determine which particular lineSeries called the function (better than writing a separate script for each one).

 

Would be great if Salesforce was using a known Javascript java package that had documentation but I can't seem to find that either.

 

Any insights appreciated.

 

Regards

MellowRen

Hi

 

I have a problem in getting communication between an included page and its parent page. Here is a very simplified version of two of my pages.

 

Main Page
-------------
<apex:page controller="MainPageCntr" extensions="SubPageC">
   <!-- The page -->
   <apex:outputPanel id="displayArea"> <!-- Used to rerender whole page -->
      <!-- Main Display -->
      <apex:outputPanel id="OppArea" rendered="{!switchOn}">
         <apex:form>
            <apex:commandButton action="{!switchView}" value="Do it" rerender="displayArea"/>
         </apex:form>
         <apex:include pageName="SubPage" />  <!-- The Controller of this page is SubPageC -->
         <apex:include pageName="AnotherPage" />
      </apex:outputPanel>

      <!-- Secondary Display -->
      <apex:outputPanel id="OppArea" rendered="{!switchOff}">
         <apex:form>
            <apex:commandButton action="{!switchView}" value="Go Back" rerender="displayArea"/>
         </apex:form>
         A heap of other stuff goes here.
      </apex:outputPanel>
   </apex:outputPanel>
</apex:page>

Sub Page
-------------
<apex:page controller=" SubPageC " >
   <!-- The page -->
   A whole heap of stuff but here is where I need a second clickable control.
         <!-- eg  <apex:commandButton action="{!switchView}" value="Do it" rerender="displayArea"/>  -->
</apex:page>

 

The CommandButton on the main page hides one area, including the included pages, and displays a secondary one (until a user clicks a return button). The main page, the sub-pages and this button all work fine (in reality displaying a complex set of charts and tables relating to the business).

 

The problem? I now have a requirement of putting a similar button into the subpage itself. It needs to pass data and switch the views. I can’t figure out how to rerender displayArea from the subpage. Simply using the rerender attribute doesn’t work. I have tried using JavaScript in the subpage to reload the whole page. I also put this in the main page and had JavaScript in the subpage try and call it.  I seem to get into a weird refresh / reload infinite loop.

 

    <!-- The JS function for sub-page -->
    <apex:form>
        <apex:actionFunction name="refreshTheDA" rerender="displayArea"/>
    </apex:form>

 

Does anyone know how to do this?

 

Or any ideas on what to try?

 

Regards

MellowRen

In the past few weeks I have put together a number of visualforce chart based pages with dynamic controls and everything, all with no problem. Suddenly one won't render the actual chart. After hours of trying to debug the controller, I slowly paired everything back until I am now pretty sure the problem in in my visualforce code.

 

But I can't see the mistake.

 

Anyone able to keep me out of the big white house with padded walls?

 

Visualforce 
===============================
<apex:page controller="TEST_TableLine_ActivitySummary" >
    <apex:form > 
    <apex:pageBlock title="Test">
    <!-- The Chart -->
    <apex:pageBlockSection >
    Begin
    <apex:chart height="800"  width="1200"  data="{!teDat}" id="actCh">
        <apex:legend position="right"/>
        <apex:axis type="Numeric" position="left" fields="rowAnum, rowBnum" title="Meetings Calls"/>
        <apex:axis type="Category" position="bottom" fields="pLab" title="Date" >
            <apex:chartLabel rotate="315"/>
        </apex:axis>
        <apex:lineSeries title="Jo" axis="left" xField="pLab" yField="rowAnum" strokeColor="#190710" strokeWidth="2" markerFill="#190710" markerType="cross" markerSize="4"/>
        <apex:lineSeries title="not Jo" axis="left" xField="pLab" yField="rowBnum" strokeColor="#BBAACC" strokeWidth="2" markerFill="#BBAACC" markerType="cross" markerSize="4" />
    </apex:chart>
    End
    <apex:dataTable value="{!teDat}" var="a" >
        <apex:column headerValue="Period" value="{!a.pLab}"/>
        <apex:column headerValue="NumA" value="{!a.rowAnum}"/>
        <apex:column headerValue="NumB" value="{!a.rowBnum}"/>
    </apex:dataTable>
    </apex:pageBlockSection>
    </apex:pageBlock>
    </apex:form>  
</apex:page>

Even here, the "Begin", "End" and the dataTable are things I added back in just to see if the render (they do). If I remove them, all I get is the page title. The table also shows the data is correct.

 

In case it helps, although I am pretty certain the error is not here, this is my test controller:

 

Controller 
===============================
public with sharing class TEST_TableLine_ActivitySummary {

    public List<ActivityGraph> teDat;
    
    //Constructor
    public TEST_TableLine_ActivitySummary() {
     
    }
    
    // -- The Activity Graph
    public List<ActivityGraph> getteDat() {
        
       List<ActivityGraph> activityFinalGraph = new List<ActivityGraph>();
        
        activityFinalGraph.add(new ActivityGraph('Day 1'));
        activityFinalGraph[0].addUserMeetings(0,5);
        activityFinalGraph[0].addUserMeetings(1,9);
        activityFinalGraph.add(new ActivityGraph('Day 2'));
        activityFinalGraph[1].addUserMeetings(0,8);
        activityFinalGraph[1].addUserMeetings(1,3);
        

System.debug('aFG: '+activityFinalGraph);
        return activityFinalGraph;
    }

    
    public class ActivityGraph
    {
        //STRUCT   -- Going to assume no team will ever have more than 13 people
        public String pLab { get; set; }
        public Integer rowAnum { get; set; } 
        public Integer rowBnum { get; set; } 

        //Constructors
        public ActivityGraph(String pl) 
        {
                   pLab = pl;
                rowAnum = 0;
                rowBnum = 0;
        }
        
        //Utility Methods
        public void addUserMeetings(Integer row, Integer nMtg) 
        {
            if(row == 0)  rowAnum = nMtg;
            if(row == 1)  rowBnum = nMtg;
        }
    }
}

Again the System.debug call shows that the data being returned is correct.

 

What is wrong with my chart? I am assuming it is staring me in the face but it is alluding me.

 

Regards

MellowRen

Hi

 

I have what I thought would be a simple thing but can’t work out how, or if, Visualforce charts can do it.

 

I have a set of data derived in Apex code which has:

 

  1. User Name
  2. Category
  3. Number (in category)

… and would like to graph it as such (using X, Y, Z to represent colour bars):

 

  5                             Legend
N 4   XY         Z              User X
u 3   XY         Z      Y       User Y
m 2   XYZ       YZ     XY       User Z
  1   XYZ      XYZ     XYZ
      Good     Bad     Ugly
           Category

The problem I have is that both the number of users and number of categories is not fixed (they are determined in the controller's Apex code). I can ensure every User has a value for every category (even if it is 0) so that is not a problem. In the sparse examples in the docs, I can only see how to do it when the number of categories is indetermined. They show data structures as such:

 

graph data {

    user_x

    user_y

    user_z

    category_label

    number

}

 

But since I don't know how many users I'll have (nor their names) until the code has run, I am not sure how to put the data nor the visualforce code together. I tried experimenting with things like:

 

<apex:chart height="300" width="700" data="{!activityGraph}" id="actChart">
    <apex:legend position="right"/>
    <apex:axis type="Numeric" position="left" fields="numberM" title="# Ms"/>
    <apex:axis type="Category" position="bottom" fields="catLabel" />
    <apex:barSeries title="{!activityGraph[0].userName}" axis="left" xField="catLabel" yField="{!activityGraph[0].numberM}" orientation="vertical"/>
</apex:chart>

…with the hope of embedding the barSeries into a <apex:repeat> loop. But that doesn't work.

 

I am really hoping that I am missing something simple here. Anyone got any ideas?

 

Regards

MellowRen

Hi

 

I am setting up a dashboard like information page using Visualforce. Due to a need for flexibilty on what to display based on profiles and other factors the page is essentially just a panelGrid with apex:include tags in each table cell.

 

I have one (sub-)page which produces a graph. On the main page, I would like two of these graphs, side by side, one displaying this quarter's data the other, next quarter's. Seems to me that I should be able to include the page twice and pass a parameter to let the controller know which quarter to use. I tried using URLFOR but can’t seem to get it to work:

 

<apex:outputPanel >
     <apex:include pageName="{!URLFOR($Page.FPGraph,null,[thisQtr=true])}" id="FPGraphThisQ"/>
</apex:outputPanel>

--------------------------------------------------------------------------------------
Visualforce Error

The name can only contain underscores and alphanumeric characters. It must begin with a letter and be unique, and must not include spaces, end with an underscore, or contain two consecutive underscores.

Seems like pageName doesn’t accept an actual URL or I am configuring the URLFOR wrong.

 

Is there a way to do this, or another tact I could take?

 

Regards

MellowRen

Hi

 

I am hopefully missing something basic here. I have a number of Visualforce generated charts that I would like to display on a single page as a sort of Dashboard. I would like them to be in columns, preferably like this:

 

   [ Chart 1 ]  [ Chart 2 ]  [ Chart 3 ]

   [ Chart 4 ]  [ Chart 5 ]  [ Chart 6 ] 

 

Yes, much the same way that you can build a Dashboard using the Dashboards. [Side Question: Can you put a Visualforce Page, i.e. a chart, inside a Dashboard? I couldn't see a way.]

 

Can this be done?

 

Regards

MellowRen

Hi

 

I am hoping that this is an easy question.

 

Some time ago I wrote a wrapper class for Opportunity Line Items. It does a heap of useful stuff for me and is used in multiple extensions (and, as such, VF pages).

 

Anyway, we are about start using Quotes. Quote Line Items and Opportunity Line Items are almost identical and most of the functions in the wrapper class I would like to reuse.

 

public class OpportunityLineItem_VF_Wrapper {

    // Getters & Setters
    public OpportunityLineItem oli {get;set;} //the OLI being edited/extended.
    public String uniqueID{get; set;}
    public String quantityText{get; set;}
    
    // a heap of other variables

    // Constructor
    public OpportunityLineItem_VF_Wrapper(OpportunityLineItem theOLI) {
oli = theOLI; //etc, etc

 

I could just copy the whole thing and maintain two sets of code but it seems to me that it would be better to have two constructors, one for OLIs and one for QLIs. I am not sure in Apex how I define the variable though (for the moment let's assume the name stays as "oli"):

 

  1. Can I define a public variable with class-wide scope in a Constructor?
  2. Can I define 'oli' as as some sort of base class?
  3. Can I subvert a 'qli' object as an 'oli' one? [ oli = (oli) theOLI; ]

Or any other workable way?

 

Would appreciate any pointers of things to consider.

 

Regards

MellowRen

Hi

 

Anyone else having this problem since Summer 13? When I refresh our Sandbox it only copies over our Custom price books but not the Standard one. Naturally this makes some of my (fully working in Production) code just die. To top it off, you can't actually create a Standard pricebook.

 

It started happening immediately after Summer 13 was released (where they "promoted" the Pricebook object) so I assume I can't be the only victim.

 

Anyone figure out a workaround?

 

Regards

MellowRen

HI

 

I have a page that needs to do the occasional calculation then show the results afterwards which entails a section of the page to be rerendered. If the focus was within the rerendered area then the focus is lost. I want to put it back. I am aware that a lot of components that have an Action attribute also have a Focus attribute. Problem is I can't figure out how to tell it to return the focus to where it was. I am hoping that there is something like this:

 

focus="{!$CurrentPage.getComponentID.CurrentFocus}"

 

That would make life so easy. Not afraid of APEX or Javascript if they present a solution. Any and all help appreciated.

 

Regards

MellowRen

Trying my hand at Extension Javascript interaction but can't seem to get the Action method to run.

 

Just stripped my page to the bare essence.

 

----------------
Visualforce Page
----------------

<apex:page StandardController="Opportunity" extensions="Opp_Edit_Extension">
    <apex:form id="WholePage">
    
        <!-- ActionFunctions -->
        <apex:actionFunction name="showPageIsTrue" action="{!showMainPageToTrue}" reRender="WholePage"/>

        <script type="text/javascript">
            var isOppApp = (true == true);
            if(!isOppApp) {
                alert('Huh?');
            } else {
                showPageIsTrue();
            }
        </script>

        <apex:actionRegion rendered="{!IF(showMainPage, false, true)}">
            <apex:pageBlock mode="edit" title="Error">
                Don't want to see this.
            </apex:pageBlock>
        </apex:actionRegion>
        
        <apex:actionRegion rendered="{!IF(showMainPage, true, false)}">
            <apex:pageBlock mode="edit" title="Yah!">
                This be good.
            </apex:pageBlock>
         </apex:actionRegion>
    </apex:form>
</apex:page>

----------------
Extension
----------------

public with sharing class Opp_Edit_Extension {
    // Getters & Setters
    public Boolean showMainPage{get; set;}
   
    // Constructor
    public Opp_Edit_Extension(ApexPages.StandardController controller) {
        //set up initial values
        showMainPage = false;
        system.debug(showMainPage);
    }
    
    // Action methods
    public PageReference showMainPageToTrue() {
        showMainPage = true;
        system.debug(showMainPage);
        return null;
    }
}

 

If I run this the page displays the "Don't want to see this." message. If I look at the logs, I can see the "Debug|false" but no "Debug|true" so it appears that either my JavaScript is not calling the ActionFunction or the ActionFunction is not calling the Extension method. 

 

Can anyone tell me what mistake I have made?

 

Regards

MellowRen

Hi

 

Can anyone help with this? I have what is a pretty simple (for the moment) visualforce page:

 

<apex:page StandardController="Opportunity">

    <apex:outputText id="myURLx" value="https://cs2.salesforce.com/home/home.jsp" />
    
    <script type="text/javascript">
        var a = document.getElementById('{!$Component.myURLx}');
        alert(a);
    </script>

    <!-- Rest of Visualforce page, just shows the Opportunity ID and Name -->

</apex:page>

 

My expectation is that the alert should show a message that says "https://cs2.salesforce.com/home/home.jsp" but rather I get "[object HTMLSpanElement]". I have found that replacing the URL in the value attribute with "hello" produces the same result. The OutputText itself is displaying the expect value on the rendered page. I have tried changing the definition of 'a' to these:

 

var a = document.getElementById('{!$Component.myURLx}').value;
var a = document.getElementById('{!$Component.myURLx}').text;
var a = document.getElementById('{!$Component.myURLx}').html;
var a = document.getElementById('{!$Component.myURLx}').string;
var a = document.getElementById('{!$Component.myURLx}').asString;

 

But the alert then just states "undefined". I tried using Apex:Variable instead of OutputText but the javascript refused to run.

 

My Google searches seem to suggest the above *should* work. I am really hoping that I have just made a silly error that is eluding my strained brain.

 

Any ideas?

 

Regards

MellowRen

I have a InputText object with an embedded ActionSupport that activates with the OnChange event to call a method from the Controller Extension. In reduced form here:

 

<apex:pageBlockSection showHeader="True" columns="2" title="Pricing" id="pricingBlock”>
   <apex:pageBlockSectionItem >
      <apex:outputLabel value="Discount" for="discProxy"/><apex:inputText value="{!discountText}" id="discProxy”>
         <apex:actionSupport event="onchange" 
                             action="{!afterDiscChange}" 
                             rerender="pricingBlock" />
      </apex:inputText>
   </apex:pageBlockSectionItem>
</apex:pageBlockSection>

 

It works perfectly except when someone changes the value in the text field and then immediately clicks on the Save button (or hits return which invokes the Save button). ie Does not click (or tab) elsewhere first. In this case, the code in afterDiscChange() is not executed and since it is meant to change a field value that we subsequently want saved it leads to an unwanted/unexpected result.

 

I tried replacing onchange with onblur but got the same (non)result.

 

Anyone come across this problem? Got any ideas on what I can do here? The simpler the better but I am not shy on doing coding if that's what it takes.

 

Further Information: I actually have more than one ActionSupport enabled InputText in this PageBlockSection, each with its own individual method attached. All work fine but are likewise not called if the Save button is immediately pressed. The methods are mutually destructive so I can't simply call them all as part of the save process. I could have the save method call the correct one if I had a way of determining which specific InputText was the one that was edited (assuming, of course, the just changed value of discountText is actually passed back to the Extension—might go System.Debug that to have a look).

 

 

Hi, I might be missing something very simple here.

 

Is it possible to use InputField, or an alternate tag, that is not connected to a field in the database? ie It is for entering a value that is passed to the controller but isn't stored once the record is saved. Essentially, I'd like the user interface to have a set of fields that the user can enter data in, the controller processes that data and populates a "real" field—a helping-to-ensure-the-quality-of-data thing.

 

I could simply create extra fields in the database but having storage set aside for data that has no value and will never be used ever again irks me a bit.

 

Or is this the only option?

 

Regards

MellowRen

Hi

 

I wrote a visualforce page and what I thought was a cool chunk of javascript which, when executed, copies values in the page from some inputfields to others (without updating the record—user can still save or cancel). It works fine except in the case of two fields which are a controller/dependent picklist pair. Boiled right down, the problem code is here:

 

document.getElementById(DestContPListID).value = document.getElementById(SourceContPListID).value;
document.getElementById(DestDepdPListID).value = document.getElementById(SourceDepdPListID).value;

 

The first line populates the controller picklist correctly but despite the second line the dependent picklist does not gain a value (most of the time). The reason seems to be that after I set the Controller picklist value (eg Tea) the dependent picklist does not show the possible values (eg English Breakfast, Earl Grey, Oolong, etc) and even when the code attempts to set it to one of these allowed values the field remains blank.

 

Note, I have tried manually setting the Controller Picklist to the desired value first (ie Tea) and then the dependent displays the possible values. If I run the script afterwards, it works fine. I assume I need something like this:

 

document.getElementById(DestContPListID).value = document.getElementById(SourceContPListID).value;
document.getElementById(SourceContPListID).systemMethodWhichKicksTheStandardControllerIntoActionToUpdateElementsOnPage;
...

 Or may be not. 

 

BTW, I am using "pure" javascript. Haven't venture into using the AJAX Toolkit yet but willing to try if it is the solution here.

 

Thanks for any help.

 

Regards

MellowRen

 

Just thought I would alert the community to this issue in case anyone else falls into the same trap.

 

Please note that when referring to Workflow Actions here I am talking about Immediate Actions rather than Time-Dependent Actions. I have not tested how this is affected by Time-Dependent Actions because my Workflow criteria requires the "Every time a record is created or edited" option. If you don't need this option then Time-Dependent Actions may be a possible solution.

 

Background

 

Anyone who does a lot of Workflow based work knows that when one executes it does so in the following order:

 

  1.      All field updates (although not in any specific order).
  2.      All other workflow actions (again not in any specific order).

You can find this in Salesforce's public documentation and are also taught it in the Advanced Administration courses.

 

     Example 

           From: https://help.salesforce.com/HTViewHelpDoc?id=workflow_rules_considerations.htm&language=en_US )

          Quote: "The order in which individual actions and types of actions are executed is not guaranteed. However, field

                       update actions are executed first, followed by other actions."

 

Personally, I have put together a lot of Workflows that rely on this behaviour. Generally I have emails sent out that include the updated values of the record.

 

The Problem

 

Some time ago Salesforce added the ability to use Visualforce based email templates for Workflow Email Alerts. This is great but, rather unexpectedly, it breaks the above behaviour. The technical reasons are a bit complex but for all intents and purposes the new order is now:

 

  1.      All Visualforce based Email Alerts (not in any specific order).
  2.      All field updates (not in any specific order).
  3.      All other Workflow actions including non-Visualforce based Email Alerts (not in any specific order).

So, if like me, you want to enhance the utility of your Workflows by replacing your HTML/Custom templates with Visualforce templates you may get nonsense results.

 

The Solution

 

Salesforce are not going to fix this. Sorry, let me rephrase. Salesforce are not going to change this, as they have now declared that this is the behaviour-by-design [sighing smiles all round by those that have dealt with Support on technical issues].

 

Essentially you have these options:

 

  1.     Don't use Visualforce based templates if you require the updated field values to be in the email.
  2.     Use Before triggers to update the fields (since Before triggers are executed before Workflows).

If Time-Dependent Actions are available to your Workflows these may solve this problem. May be someone else can comment. 

 

Small Rant

 

This section is not important to the information above, feel free to not waste your time and stop reading.

 

As indicated I went through one of those typical support scenarios of spending an amazing amount of time (counting in weeks) and effort to essentially prove to Salesforce that their system was not working as advertised and pass me along to someone who understood the system technically enough to have a proper look at it. Within hours of the senior T3 tech taking over the case and stating that he was able to "replicate the scenario" I got back the dreaded "we are now declaring this to be the correct behaviour" comment. My big concern in this particular case though is that the UI provides no warning of this new "correct" behaviour and the documentation directly contradicts it. I was told that their documentation team had now been informed and that the documentation, at least, would be updated. My case closed over a month ago yet no updates (hence this post). Rant, rant. Sigh.

 

I hope this is helpful to someone.

Hi

 

In most chart related tags there is an attribute called rendererFn which is usually defined in the docs as “A string that specifies the name of a JavaScript function that augments or overrides how each data point is rendered. Implement to provide additional styling or to augment data.”

 

Well that’s nice. May be I am looking in the wrong place (or using the wrong search terms) but I can’t seem to find any documentation on the format required for these functions. There is one repeated code example that someone wrote (I think this is the original source, apologies to the author if not).

 

The thing I find fascinating is that in the Visualforce tag the attribute is written as rendererFn="renderer" yet the function definition has two parameters function renderer(klass, item).

 

I have tested this code and it fully works so the author is correct. Does anyone know where I can get the definition of klass and item and how to interact with them? Or can anyone with better Javascript knowledge make an educated guess? “item” allows you do access the data record values (e.g. var type = item.storeItem.get('ctype'); ). I have no idea how that works but it does and it is easy enough to modify for my own data structures. What other information can be pulled out of these variables?

 

My main goal is to be able to get more information about what item is being hovered over (actually clicked but regardless same problem). For instance, my chart has multiple lineSeries tags. I am wondering if through klass or item I can determine which particular lineSeries called the function (better than writing a separate script for each one).

 

Would be great if Salesforce was using a known Javascript java package that had documentation but I can't seem to find that either.

 

Any insights appreciated.

 

Regards

MellowRen

Hi Experts, 

 I am using below simple formula to save and not able to save due to some limation not sure what is the issue in below formula I tried both using CASE and NESTED IF both giving the same error message 
 
IF
 
IF((infer3__Infer_Rating__c & TEXT(inferb1__brating__c) =  'A1'), '1-A1',
IF((infer3__Infer_Rating__c & TEXT(inferb1__brating__c) =  'A2'), '2-A2',
IF((infer3__Infer_Rating__c & TEXT(inferb1__brating__c) =  'B1'), '3-B1',
IF((infer3__Infer_Rating__c & TEXT(inferb1__brating__c) =  'B2'), '4-B2',
IF((infer3__Infer_Rating__c & TEXT(inferb1__brating__c) =  'A3'), '5-A3',
IF((infer3__Infer_Rating__c & TEXT(inferb1__brating__c) =  'A4'), '6-A4',
IF((infer3__Infer_Rating__c & TEXT(inferb1__brating__c) =  'B3'), '7-B3',
IF((infer3__Infer_Rating__c & TEXT(inferb1__brating__c) =  'B4'), '8-B4',
IF((infer3__Infer_Rating__c & TEXT(inferb1__brating__c) =  'C1'), '9-C1',
IF((infer3__Infer_Rating__c & TEXT(inferb1__brating__c) =  'C2'), '10-C2',
'100'
))))))))))
 
CASE
 
CASE(
infer3__Infer_Rating__c & TEXT(inferb1__brating__c), 
'A1', '1-A1',
'A2', '2-A2',
'B1', '3-B1',
'B2', '4-B2',
'A3', '5-A3',
'A4', '6-A4',
'B3', '7-B3',
'B4', '8-B4',
'C1', '9-C1',
'C2', '10-C2'
,'100')

Please suggest me how to fix this issue. 

Thanks
Sudhir
  • June 15, 2016
  • Like
  • 0
HI Guys,

I want a formula like below.
eg Site XYZ: was booked for 7 days in total in February – formula looks to calendar to determine # days in month and account for leap year or not. The 7 days booked/ 29 days in leap year = 24.13% for Feb 2016/ If booking starts in previous month, or overflows to next month, the days in the previous and next month should not be calculated as part of the February occupancy. Eg starts 28 Feb so only 2 days BOOKED for Feb should count – 28 + 29 Feb

I wanted to showcase the same in report as below

User-added image

Right now I'm showing it as no of days booked b/w start and end dates based on start month. If it was booked b/w two months I want only those no of days booked in current month and remaining should go to next month. Any help is appreciated.

Thanks in Advance,
Sandeep Kumar
I only want the third word from the strings, I am stucked with the third formula , can anybody help me out...Here what I am trying : IF( NOT( ISBLANK(Name)) ,RIGHT( Name , ((LEN(Name) - FIND("", Name)) - FIND("",Name))  , MID(Name,Find(" ",Name,Find(" ",Name,1)+1)+1,Find(" ",Name,Find(" ",Name,Find(" ",Name,1)+1)+1)-(Find(" ",Name,Find(" ",Name,1)+1)+1)))
But not getting correct O/P ,when Name contains only three words. It work well when Name has four word in it.
Please help me out with the formula.
 
Hi my scenario is to restrict the user,if they try to edit the opportunity record after the three business days from the ClosedDate field. For example : if i update the opportunity after three days from the ClosedDate(5/12/2016), it will through an alart message, then if i edit the ClosedDate as 5/13/2016 then the record will save. But by requirement is to restrict the update operation itself. 
(CASE( 
MOD( CloseDate - DATE(1900, 1, 7), 7), 
0, CloseDate+3, 
1, CloseDate+3, 
2, CloseDate+3, 
3, CloseDate+5, 
4, CloseDate+5, 
5, CloseDate+5, 
6, CloseDate+4, 

CloseDate))<=TODAY()

 
I recently created a validation rule preventing all users not designated as "System Admin" from changing the stage of an opportunity to closed won or closed lost.  However, I see that the opportunity owner can still make changed regardless of this VR.  Is there anyway I can restric the record owner from making these changes so that the System Admins have exclusive access.  I have professional edition by the way.

And here is my VR 

AND( 
$UserRole.Name <> "System Admin", 
ISCHANGED(StageName), 
ISPICKVAL(StageName,"1 - Closed Won"), 
ISPICKVAL(StageName,"0 - Closed Lost"))
Hi - I have a need for a formula with multiple OR conditions in a Workflow rule

For example,
IF (Preferred_Language__c does NOT equal English, or Spanish, or French, or Mandarin 
THEN
(update field called Let_Template to English)

Thank you.
 
Trying to determine a more efficient way to write the below formula.  Basically it evaluates the current day of the week, and if Monday - Thursday (e.g. 1-4)  and it's before 1PM then return Today, else return Today + 1. IF the day is Friday before 1PM then return Today, else Today + 3. If Saturday (6), return Today + 2. If Sunday (7), return today +2

IF(
                OR(CM_Test_Date_Field__c = "1",CM_Test_Date_Field__c = "2",CM_Test_Date_Field__c = "3",CM_Test_Date_Field__c = "4",CM_Test_Date_Field__c = "7"),
                IF(NOW() < DATETIMEVALUE(TODAY())+(19/24), TEXT(YEAR(TODAY())) + LPAD(TEXT(MONTH(TODAY())),2,"0") + LPAD(TEXT(DAY(TODAY())),2,"0"), TEXT(YEAR(TODAY()+1)) + LPAD(TEXT(MONTH(TODAY()+1)),2,"0") + LPAD(TEXT(DAY(TODAY()+1)),2,"0")),
                IF(CM_Test_Date_Field__c = "5",IF(NOW() < DATETIMEVALUE(TODAY())+(19/24), TEXT(YEAR(TODAY())) + LPAD(TEXT(MONTH(TODAY())),2,"0") + LPAD(TEXT(DAY(TODAY())),2,"0"), TEXT(YEAR(TODAY()+3)) + LPAD(TEXT(MONTH(TODAY()+3)),2,"0") + LPAD(TEXT(DAY(TODAY()+3)),2,"0")),TEXT(YEAR(TODAY()+2)) + LPAD(TEXT(MONTH(TODAY()+2)),2,"0") + LPAD(TEXT(DAY(TODAY()+2)),2,"0")))
 
Hello everyone,
 can you explain a anyone  how to install app through appexchange:
if i am trying to install an app  i am getting the error like this:

Oops! Looks like you don't have permission to install apps.
This problem any body know solution explain
Thanks &Regards


 
  • March 30, 2015
  • Like
  • 0
Hi

I am putting together a system and something is going awefully wrong. May be I am too tired but I simply can't understand what is going on.

I have two Objects "Prod" and "Prod Detail" in a Master/Detail relationship. I have a Visualforce page "ProdEdit" for Prod with an extension. I want the page to have a button that takes a User (supplied) and adds a Prod Detail record. I have done similar tings to this before but this is not working. I have copied over a reduced set of code to my developer account and get the same behaviour.

The Page:
Hi
 
I am putting together a system and something is going awfully wrong. May be I am too tired but I simply can't understand what is going on.
 
I have two Objects "Prod" and "Prod Detail" in a Master/Detail relationship. I have a Visualforce page "ProdEdit" for Prod with an extension. I want the page to have a button that takes a User (supplied) and adds a Prod Detail record. I have done similar tings to this before but this is not working. I have copied over a reduced set of code to my developer account and get the same behavior.
<apex:page standardcontroller="Prod__c" extensions="Prod_Edit_Ext">
    <!-- The page -->
    <apex:form id="thePage">
        
    	<!-- In View Mode: Has Options Lists. -->
        	<apex:pageBlock title="Prod Detail" mode="maindetail">
                <apex:pageBlockSection title="Information" columns="2">
                    <apex:outputField value="{!Prod__c.Name}"/>
                    <apex:outputField value="{!Prod__c.Manufacturer__c}"/>
                    <apex:outputField value="{!Prod__c.OwnerId}" label="Prod Manager"/>
                </apex:pageBlockSection>
                <br/><br/>
            </apex:pageBlock>
         	<apex:pageBlock mode="edit">
                <apex:pageBlockSection columns="2" id="newPD">
                    <apex:inputField label="New Manager" value="{!newProdDetailWithUser.User__c}"/>
                    <apex:commandButton value="Add Prod Detail" action="{!addProdDetail}" immediate="true"/>
                </apex:pageBlockSection>
        </apex:pageBlock>                        
    </apex:form>
</apex:page>

The Extension
public class Prod_Edit_Ext {
    //Variables
    private ApexPages.StandardController stdProdCtrl; //for a link to the Controller class (that this is extending) so as to use its methods.
    private Prod__c  theProd;
        
    //Getters & Setters (Simple)
    public Prod_Detail__c newProdDetailWithUser {get; set;}
    
	//Constructor
    public Prod_Edit_Ext(ApexPages.StandardController controller) {
System.debug('zzz In Constructor');
        stdProdCtrl = controller;
        theProd = (Prod__c) stdProdCtrl.getRecord(); //use std controller to get record.

        //Initialise Prod Details
        newProdDetailWithUser = new Prod_Detail__c();
    }
    
    //Action Methods
    public void addProdDetail() {
        // This function runs when a user hits "add" button.
System.debug('zzz Start Add: '+newProdDetailWithUser);
       // if (newProdDetailWithUser.User__c != null) {
            newProdDetailWithUser.Prod__c = theProd.Id;
            newProdDetailWithUser.Name = 'Test: '+Datetime.now().format();
System.debug('zzz Ready to insert: '+newProdDetailWithUser);
System.debug('zzz User to insert: '+newProdDetailWithUser.User__c);
            INSERT newProdDetailWithUser;
System.debug('zzz Inserted: '+newProdDetailWithUser);
      //  }
        newProdDetailWithUser = new Prod_Detail__c();
    }
}

This is creating bizarre results:
  1. When I first load the page, a record is created even though the button is not yet pushed.
  2. After I select a User in the field, and press the button, a Prod Detail record is created but only with the Name (and the Prod link) but not with the User I just selected. That field is left blank. The debug statements show it is null before the Insert.
I am going stir-crazy. I have experimented with page block modes, full on getters and setters, etc but cannot get it to work. Would really appreciate if someone was able to tell me what I have done wrong.

Regards
MellowRen
Hi All,
 Can any one help me to increase my test class code coverage to 100%, This is my first test class, Now my test class coverage is 87%, I want to increase the code coverage to 100%, What are the changes i need to do in my test class to get code coverage of 100%?

Thanks in advance.

my controller class
================
public with sharing class AccountListViewTaskCon {
     public Id accountId                                {    get; set;    }
     public Boolean pbTablebool                         {    get; set;    } // boolean value to render pageblocktable
     public String SearchAccName                        {    get; set;    }
     public String queryString                          {    get; set;    }
     List <Account> accounts;
     public Apexpages.StandardSetController controller    {get; set;}
    
     public AccountListViewTaskCon()
     {
        controller    = new ApexPages.StandardSetController(Database.getQueryLocator([SELECT Name,Industry,Rating,Account_Priority__c,Owner.Name,Account_Region__c FROM Account]));
        controller.setPageSize(20);
        pbTablebool  = True;           
     }
    public List<Account> getAccounts()
    {
        return (List<Account>) controller.getRecords();
    }
    public void doDelete()
    {
       try
        {
            delete [select Id from Account where Id =: accountId];
        }
        catch(Exception e)
        {
               ApexPages.addmessage(new ApexPages.message(ApexPages.severity.ERROR, e.getMessage()));
        }//try
    }
    public void doSearch()
    {
        try{
            //null or empty check
            System.debug('SearchAccName : '+SearchAccName);
            queryString = 'select id,Name,Industry,Rating,Account_Priority__c,Owner.Name,Account_Region__c from Account  where Name Like \''+SearchAccName+'%\' ';
            controller    = new ApexPages.StandardSetController(Database.Query(queryString ));
          }
        catch(System.QueryException qe)// exception handling
        {
          ApexPages.Message msg = new ApexPages.Message(ApexPages.Severity.error, qe.getMessage());
          ApexPages.addMessage(msg);
        }
    }
    // indicates whether there are more records after the current page set.
    public Boolean hasNext
    {
        get {
            return controller.getHasNext();
        }
        set;
    }

    // indicates whether there are more records before the current page set.
    public Boolean hasPrevious {
        get {
            return controller.getHasPrevious();
        }
        set;
    }
    // returns the page number of the current page set
    public Integer pageNumber {
        get {
            return controller.getPageNumber();
        }
        set;
    }
    // returns the first page of records
     public void first() {
         controller.first();
     }

     // returns the last page of records
     public void last() {
         controller.last();
     }

     // returns the previous page of records
     public void previous() {
         controller.previous();
     }

     // returns the next page of records
     public void next() {
         controller.next();
     }

     // returns the PageReference of the original page, if known, or the home page.
     public void cancel() {
         controller.cancel();
     }
}

My test class
==========

@isTest(SeeAllData=true)

public class TestAccountListViewTaskCon
{
        public static boolean returnValueBooleanhasNext ;
        
        public static boolean returnValueBooleanhasPrevious  ;
        public static integer pageNumber ;
       
        public static  AccountListViewTaskCon objAccountListViewTaskConPageCon ; 
        static testMethod void runPositiveTestCases() 
        {
             objAccountListViewTaskConPageCon =  new AccountListViewTaskCon(); 
            system.Test.startTest();
            objAccountListViewTaskConPageCon.getAccounts();
            objAccountListViewTaskConPageCon.doDelete();
            objAccountListViewTaskConPageCon.doSearch();
            objAccountListViewTaskConPageCon.first();
            objAccountListViewTaskConPageCon.last();
            objAccountListViewTaskConPageCon.previous();
            objAccountListViewTaskConPageCon.next();
            objAccountListViewTaskConPageCon.cancel();
            returnValueBooleanhasNext  = objAccountListViewTaskConPageCon.hasNext;
            returnValueBooleanhasPrevious  = objAccountListViewTaskConPageCon.hasPrevious; 
             pageNumber =  objAccountListViewTaskConPageCon.pageNumber ;
            System.assertEquals(false, returnValueBooleanhasNext  );
            System.assertEquals(false, returnValueBooleanhasPrevious  );
System.assertEquals(1, pageNumber );
system.Test.stopTest();

        }
      
}
  • March 11, 2015
  • Like
  • 0
Hi everybody,
I created two custom objects in master-detail relationship: "Operation"(master) and "Activity" (detail).
In activity, among the others, there are two fields: "start date" and "close date". I need a way to prevent that "start date" of "activity n" can't be set before "close date" of "acitivity n-1".
I tried with validation rules and creating two different record types for activity but I didn't get it.
Do you have any idea?

Many Thanks!

Under my CONTACTS object, I have a picklist that asks "How did you hear about us".  The picklist options are: Internet, Friend/Family, Church, Ad/Print, Event, Other.  I would like a text field to be filled in when any of these choices are chosen so that we know more detail.  What would the validation rule formula be? 

 

I inserted:

AND(NOT(ISPICKVAL( How_Did_You_Find_Out_About_ZOE__c , "Event")),

NOT(ISBLANK( Event_Name__c )))

 

The formula is not working properly!  I tested the formula choosing another option besides EVENT and it wouldn't let me save.

 

Also, is there a way to make the text field ONLY SHOW UP when a certain option is chosen from the picklist?  For example, the the EVENT NAME text field only show up when EVENT is chosen in the picklist?

 

THANKS!

  • August 21, 2013
  • Like
  • 0

Hi

 

I have what I thought would be a simple thing but can’t work out how, or if, Visualforce charts can do it.

 

I have a set of data derived in Apex code which has:

 

  1. User Name
  2. Category
  3. Number (in category)

… and would like to graph it as such (using X, Y, Z to represent colour bars):

 

  5                             Legend
N 4   XY         Z              User X
u 3   XY         Z      Y       User Y
m 2   XYZ       YZ     XY       User Z
  1   XYZ      XYZ     XYZ
      Good     Bad     Ugly
           Category

The problem I have is that both the number of users and number of categories is not fixed (they are determined in the controller's Apex code). I can ensure every User has a value for every category (even if it is 0) so that is not a problem. In the sparse examples in the docs, I can only see how to do it when the number of categories is indetermined. They show data structures as such:

 

graph data {

    user_x

    user_y

    user_z

    category_label

    number

}

 

But since I don't know how many users I'll have (nor their names) until the code has run, I am not sure how to put the data nor the visualforce code together. I tried experimenting with things like:

 

<apex:chart height="300" width="700" data="{!activityGraph}" id="actChart">
    <apex:legend position="right"/>
    <apex:axis type="Numeric" position="left" fields="numberM" title="# Ms"/>
    <apex:axis type="Category" position="bottom" fields="catLabel" />
    <apex:barSeries title="{!activityGraph[0].userName}" axis="left" xField="catLabel" yField="{!activityGraph[0].numberM}" orientation="vertical"/>
</apex:chart>

…with the hope of embedding the barSeries into a <apex:repeat> loop. But that doesn't work.

 

I am really hoping that I am missing something simple here. Anyone got any ideas?

 

Regards

MellowRen

Hi

 

I am hopefully missing something basic here. I have a number of Visualforce generated charts that I would like to display on a single page as a sort of Dashboard. I would like them to be in columns, preferably like this:

 

   [ Chart 1 ]  [ Chart 2 ]  [ Chart 3 ]

   [ Chart 4 ]  [ Chart 5 ]  [ Chart 6 ] 

 

Yes, much the same way that you can build a Dashboard using the Dashboards. [Side Question: Can you put a Visualforce Page, i.e. a chart, inside a Dashboard? I couldn't see a way.]

 

Can this be done?

 

Regards

MellowRen

What is wrong with my code? After i execute it,  annualvalue dont change...

public class ChangeValue{
    public ChangeValue(){
        List<Contact> cts = [SELECT ID, AccountID from Contact Where Name = 'test'];
		//Get list of account IDs    
		Set<ID> accountids = new Set<ID>();
        for(Contact ct: cts) if(ct.AccountID!=null){
        	accountids.add(ct.AccountID);}
        if(accountids.size()>0)
        {
            List<Account> accounts = [Select ID, AnnualRevenue 
                                      from Account where ID in :accountids];
            for(Account accountfound: accounts)
                if(accountfound.AnnualRevenue != 0)
                accountfound.AnnualRevenue = 500;
            update accounts;
        }
    }    
}

 

Summer '13 has a long awaited feature of mine - Cross-Object Owner Formulas.  As a developer, I can't count the number of times that I have written a trigger on objects for clients to populate a custom user lookup so they could use it in formula fields.  Almost every sObject has the owner field but it's polymorphic, meaning it can point to a queue or user. This presented Salesforce.com with a problem in their data model using formulas.  For instance, if Salesforce.com allowed you to reference Owner.FirstName and the owner was a queue, you would receive a runtime exception. Now there is native support for using cross-object formulas for all Owner fields.  The syntax is slightly different than normal.  For instance, the syntax to show a custom field from the User object would be Owner:User.MyCustomField__c.  You can also determine if the record is owned by a queue in a validation rule ISBLANK(Owner:User.Id). 

What new features are you excited about in the upcoming release?