• Benzy
  • NEWBIE
  • 50 Points
  • Member since 2014

  • Chatter
    Feed
  • 0
    Best Answers
  • 4
    Likes Received
  • 0
    Likes Given
  • 12
    Questions
  • 17
    Replies
I am using the apex:map component in a Visualforce page. I can successfully render a map using coordinates pulled through an apex class.

However, the resulting location on the Visualforce page is slightly different to that shown if I put the same coordinates directly into Google Maps. (See maps below)

Does anyone know why this is happening?

VF page map code
 
<!-- Display the address on a map -->
        <apex:map width="600px" height="400px" mapType="roadmap" zoomLevel="17" center="{!program.Location__r.LatitudeTEXT__c},{!program.Location__r.LongitudeTEXT__c}">
            <apex:mapMarker title="" position="{!program.Location__r.LatitudeTEXT__c},{!program.Location__r.LongitudeTEXT__c}"/>
        </apex:map>

Visualforce Page Map
(you can see the coordinates returned from the apex class just above the map - these are what the map is using.)

User-added image

Google Map
(notice coordinates are the same as the VF page, but pin location is different)

User-added image
  • May 13, 2015
  • Like
  • 0
Hi,

I have created a visualforce email template that contains a .ics calendar invite attachment. The attachment works fine for desktop/phone apps. But Gmail (using the web interface) will not recognise the .ics file and give the "Add to Calendar" option in the message. 

What I want is for the attached invite to appear in the email as so:
User-added image
Instead, it just appears as a regular attachment, with the only option being to download it.

I have created a calendar event in google calendar, downloaded it and emailed it to myself, and it works as per the image above. However, I put the exact same code in my VF template and send a test, and the invite doesn't work as above.

Here is my vf code (note that there are no merge fields in the invite code because I'm simply trying to get a basic invite to work). Can anyone see where I am going wrong? Thanks
 
<messaging:emailTemplate subject="Leave Request Approved" recipientType="User" relatedToType="Leave_Request__c">
<messaging:htmlEmailBody >
<html>

<style type="text/css">
...my styling...
</style>

<body>
 
...my body content...

</body>
</html>
</messaging:htmlEmailBody>
 
<messaging:attachment filename="reminder.ics">
BEGIN:VCALENDAR
VERSION:2.0
CALSCALE:GREGORIAN
BEGIN:VEVENT
STATUS:CONFIRMED
CREATED:20150507T054355Z
UID:qjvkvr7gsf10erbp9vc2fk05ec@google.com
DTEND;VALUE=DATE:20150510
TRANSP:TRANSPARENT
SUMMARY:Test Summary
DTSTART;VALUE=DATE:20150508
DTSTAMP:20150507T054355Z
LAST-MODIFIED:20150507T054355Z
SEQUENCE:0
DESCRIPTION:Test Description
END:VEVENT
END:VCALENDAR
</messaging:attachment>
 
</messaging:emailTemplate>

 
  • May 07, 2015
  • Like
  • 1
Hi,

I'm trying to change the background colour of a DIV on a VF page based on the value of a field. Since I have multiple options, it seems the best way to do this is to use the CASE function. However, I can't seem to get it to work. 

I have the follwing code:
<div class="programstatus" style="background-color:{!CASE(program.Program_Status__c == 'Applications Open', '#67AC34', program.Program_Status__c == 'Applications Closed' , '#F12923' )}">
                <apex:outputText value="{!program.Program_Status__c}"></apex:outputText>
                </div>

However, when I try to save, I get the following error: Error: Incorrect argument type for function 'CASE()'.

Any idea I'm doing wrong?
Thanks
  • April 26, 2015
  • Like
  • 0
I've created a Visualforce page that lists a bunch of interview time slots with a link for people to reserve them. One of the columns is showing a date/time field. Since it is a public visualforce page, the date/time field defaults to GMT.

I would like to have a picklist containing all the time zones (worldwide), where the user selects their time zone from the list and then the date/time column updates to show the times based on the newly selected time zone.

I have gotten as far as creating the apex class and vf page which almost does the trick for the current system time (which is not very far!). I figure it's a good first step, but need some help as I'm stuck. I'm struggling to get the picklist value to pass into the timezone part of the apex class. Any ideas?

Thanks

Apex Class
public class ConvertTimeZone { 
    public String YourTimeZone {get;set;}
    public String tzOptions {get;set;}
    public String YourInterviewTime{get;set;}
    
    public List<SelectOption> getTimeZoneOptions() {
        List<SelectOption> tzOptions = new List<SelectOption>();
        tzOptions.add(new SelectOption('GMT','Greenwich Mean Time'));
        tzOptions.add(new SelectOption('Australia/Sydney','Australian Eastern Daylight Time'));
        tzOptions.add(new SelectOption('Asia/Kolkata','India Standard Time'));
 
        return tzOptions;
    }
    
    public ConvertTimeZone() {
    DateTime temp = System.now();
    YourInterviewTime = temp.format('dd/MM/yyyy HH:mm a z', 'tzOptions'); 
    }
}

VF Page
<apex:page controller="ConvertTimeZone">

<apex:form >
    <apex:pageBlock title="Custom PickList Demo" id="out">
        
        <apex:pageBlockSection title="Custom Picklist Using selectList and selectOption" collapsible="false">
            <apex:actionRegion >
            <apex:selectList value="{!YourTimeZone}" multiselect="false" size="1">
                <apex:selectOptions value="{!TimeZoneOptions}"/>
            <apex:actionSupport event="onchange" rerender="yourtimezone" />
            </apex:selectList>
            </apex:actionRegion>
        <apex:actionRegion >
            <apex:outputText id="yourtimezone" value="{!YourTimeZone}" label="You have selected:"/>
        </apex:actionRegion>
        </apex:pageBlockSection>

        <apex:pageBlockSection >
        Resulting Time: <apex:actionRegion ><apex:outputText id="yourtimezone" value="{!YourInterviewTime}"/></apex:actionRegion>
        </apex:pageBlockSection>
    </apex:pageblock>
  </apex:form>
</apex:page>

 
  • April 23, 2015
  • Like
  • 0
Hi, I'm struggling to get a test class to work. Any help would be much appreciated!

Where I'm stuck is with the apex page parameter. In the test class I am trying to define this parameter and then pass it into the class (the last section of the test class). But I am totally stuck on how to get this to work.

Apex Class
public class InterviewsListDataTable {
    String Id = ApexPages.currentPage().getParameters().get('Id');
    public List<Interview_Time_Slot__c> interviewList {
        get {
            if (interviewList == null) {
                interviewList = [SELECT Interviewer_Name__c, Date_and_Time_of_Slot__c, Interviewer_Email__c, Interviewer_Skype_Name__c, Program__r.Program_Public_Name__c FROM Interview_Time_Slot__c WHERE Program__c =: Id ORDER BY Date_and_Time_of_Slot__c Asc];
            }
            return interviewList;
        }
        set;
    }
}

Test Class (work in progress)
@isTest
 private class TestInterviewsListDataTable {static testMethod void myUnitTest() {Profile pf = [Select Id from Profile where Name = 'System Administrator'];User u = new User();
 u.FirstName = 'Test';
 u.LastName = 'User';
 u.Email = 'testuser@test123456789.com';
 u.CompanyName = 'test.com';
 u.Title = 'Test User';
 u.Username = 'testuser@test123456789.com';
 u.Alias = 'testuser';
 u.CommunityNickname = 'Test User';
 u.TimeZoneSidKey = 'America/Mexico_City';
 u.LocaleSidKey = 'en_US';
 u.EmailEncodingKey = 'ISO-8859-1';
 u.ProfileId = pf.Id;
 u.LanguageLocaleKey = 'en_US';
 insert u;
system.runAs(u){


//Set RecordTypeId variable CA
 String strpRecordTypeId = [Select Id From RecordType WHERE DeveloperName = 'Fellowship' AND sobjectType = 'Program__c'].Id;

    
    Program__c program = new Program__c();
    program.Name = 'TestProgram';
    program.RecordTypeId = strpRecordTypeId;
    Insert program;
    
        Interview_Time_Slot__c objInterviewSlot = new Interview_Time_Slot__c();
        objInterviewSlot.Program__c = program.Id;
        Insert objInterviewSlot;
        
     
     PageReference PageRef = Page.Interviews;
     Test.setCurrentPage(PageRef);
     ApexPages.currentPage().getParameters().put('Id', 'program.Id'); 

     InterviewsListDataTable testlist = new InterviewsListDataTable();
     testlist.Id = program.Id;
     
     testlist.interviewList();

    }
}
}

 
  • April 21, 2015
  • Like
  • 0
I have a pageBlockTable with a number of columns.

If I use 'rendered' in a column, then the headerValue no longer displays. Eg:

<apex:column headerValue="Program" value="{!program.Program_Public_Name__c}"/> THIS SHOWS THE HEADER LABEL

<apex:column headerValue="Program" value="{!program.Program_Public_Name__c}" rendered="{!IF(program.Program_Status__c == 'Applications Open', true, false)}"/> NO HEADER LABEL FOR THIS

Any idea why?
Thanks
  • April 18, 2015
  • Like
  • 0
So I have created flows before where the flow is started from a record using a custom button, and that record's ID is passed into the flow as a variable, which is great!

However, I now want to do this but starting from a list view, where I would select (check) a bunch of records and then click a custom button to start the flow, and have the record IDs of all the checked records pass into the flow as a list of variables (I think it would be an sObject variable?)

Is this possible? 
Thanks
  • February 20, 2015
  • Like
  • 3
Hi, I have written a test class that keeps failing because of a FIELD_FILTER_VALIDATION_EXCEPTION. I have narrowed it down to the exact problem: Part of a lookup filter (that is looking up a Cash Account) specifies that returned records must have their Status__c = 'Active' (see full lookup filter below). When I remove this part of the filter lookup logic, the test class passes. When I add it back in, the test class fails again.

As you can see in my test class below, I have definitely set the Status__c for the Cash Account record insert to be 'Active'. So I just can't figure out what I'm missing that is causing the test class to fail based on this.

Any help much appreciated.

Lookup Filter:
User-added image

Validation Error:
User-added image

Test Class:
@isTest
 private class TestCashAccountRollUpCashIn {static testMethod void myUnitTest() {Profile pf = [Select Id from Profile where Name = 'System Administrator'];User u = new User();
 u.FirstName = 'Test';
 u.LastName = 'User';
 u.Email = 'testuser@test123456789.com';
 u.CompanyName = 'test.com';
 u.Title = 'Test User';
 u.Username = 'testuser@test123456789.com';
 u.Alias = 'testuser';
 u.CommunityNickname = 'Test User';
 u.TimeZoneSidKey = 'America/Mexico_City';
 u.LocaleSidKey = 'en_US';
 u.EmailEncodingKey = 'ISO-8859-1';
 u.ProfileId = pf.Id;
 u.LanguageLocaleKey = 'en_US';
 insert u;
system.runAs(u){
//Set RecordTypeId variable CA
 String strcaRecordTypeId = [Select Id From RecordType WHERE DeveloperName = 'Person' AND sobjectType = 'Cash_Account__c'].Id;
//Insert a cash account 
 Cash_Account__c ca = new Cash_Account__c();
 ca.RecordTypeId = strcaRecordTypeId;
 ca.Name = 'Test Person';
 ca.Status__c = 'Active';
insert ca;
system.assertEquals(ca.Rollup_Cash_In__c, null);
//Set RecordTypeId variable CT
 String strctRecordTypeId = [Select Id From RecordType WHERE DeveloperName = 'Person_to_Person' AND sobjectType = 'Cash_Transfer__c'].Id;
//Test payments on insert
 Cash_Transfer__c ct1 = new Cash_Transfer__c();
 ct1.RecordTypeId = strctRecordTypeId;
 ct1.Destination__c = ca.Id;
 ct1.Amount__c = 100;
 insert ct1;
Cash_Account__c cau1 = [select Rollup_Cash_In__c from Cash_Account__c where Id = :ca.Id];
 system.assertEquals(cau1.Rollup_Cash_In__c,ct1.Amount__c);
//Test payments on update
 Cash_Transfer__c ct1u = [select Amount__c from Cash_Transfer__c where Id = :ct1.Id];
 ct1u.Amount__c = 200;
 update ct1u;
Cash_Account__c cau2 = [select Rollup_Cash_In__c from Cash_Account__c where Id = :ca.Id];
 system.assertEquals(cau2.Rollup_Cash_In__c,ct1u.Amount__c);
//Test payments on second insert
 Cash_Transfer__c ct2 = new Cash_Transfer__c();
 ct2.RecordTypeId = strctRecordTypeId;
 ct2.Destination__c = ca.Id;
 ct2.Amount__c = 800;
 insert ct2;
AggregateResult ag1 = [select sum(Amount__c) from Cash_Transfer__c where Destination__c = :ca.Id];
Cash_Account__c cau3 = [select Rollup_Cash_In__c from Cash_Account__c where Id = :ca.Id];
 system.assertEquals(cau3.Rollup_Cash_In__c,ag1.get('expr0'));
//Test payment on delete
 delete ct2;
AggregateResult ag2 = [select sum(Amount__c) from Cash_Transfer__c where Destination__c = :ca.Id];
Cash_Account__c cau4 = [select Rollup_Cash_In__c from Cash_Account__c where Id = :ca.Id];
 system.assertEquals(cau4.Rollup_Cash_In__c,ag2.get('expr0'));
}
}
}

 
  • February 17, 2015
  • Like
  • 0
Hi,

I currently have a SOQL query to populate a dynamic picklist (see below). Notice that I am already filtering the list results based on the city of the current user matching that of the users returned by the query. 

Id Mgrid = [select Id,ManagerId from User where id =: userinfo.getuserid()].ManagerId;
string MgrCity = [select City from User where id =: Mgrid].city;

list<user> u = new list<user>();
u = [SELECT Id, Name FROM User WHERE City =: MgrCity AND Profile.Name = 'Pollinators' AND IsActive = TRUE ORDER BY Name ASC];

The purpose of this is so different city managers can see a list of only their team members. However, I want people above city managers (eg the admin) to see the same list but without the City condition.

Any idea how to do that?
Thanks
  • January 26, 2015
  • Like
  • 0
Hi,

I currently have an SOQL query that gets a list of users who are of a specific profile and are active, which looks like this:
[SELECT Id, Name FROM User WHERE Profile.Name = 'Pollinators' AND IsActive = TRUE ORDER BY Name ASC]

This list is used to populate a dynamic picklist that managers user to access filtered reports. However, my business is expanding into new cities and so I want to also filter this list by showing only users who are in the same city as the manager.

I figured the best way to do this is to match the City field value on the User's record page. Upon doing some reading, I found a list of UserInfo Methods, and I can't see anything in there for City.

Can anyone help with how I might acheive this?
Thanks
 
  • January 21, 2015
  • Like
  • 0
Hi,
I have a visualforce email template for purchase orders. The email is sent using a workflow.
When I (an admin) test this template, it works fine. However, when another user (not admin) uses the template, the email is sent but the subject and body are blank.
Any ideas as to why this might be?
Thanks
  • May 05, 2014
  • Like
  • 0
Hi,
I'm trying to pass a picklist value into a url, whcih then links to a report which is filtered based on that value. However, I'm getting an error when trying to save the VF page, which says Error: Unsupported attribute action in <apex:outputLink> in Special_Reports at line 10 column 75

VF Page Code:

<apex:page controller="dynamicpicklist" >
    <apex:form >
    <apex:sectionHeader title="Dynamic Picklist" subtitle="Reusable code"/>
        <apex:pageblock >
            <apex:pageBlockSection title="Dynamic picklist" columns="1">
                <apex:outputlabel value="Pollinator" for="values" />
                <apex:selectList value="{!pollinator}" size="1" id="values">
                    <apex:selectOptions value="{!pollinatornames}"/>
                </apex:selectList>
                <apex:outputLink id="link" action="{!processLinkClick}">Process Report</apex:outputLink>                                          
            </apex:pageblocksection>
        </apex:pageblock>
    </apex:form>
</apex:page>

Class:

public class dynamicpicklist
{
    public String pollinator{get; set;}

    public List<SelectOption> getpollinatornames()
        {
          List<SelectOption> options = new List<SelectOption>();
          List<User> pollinatorlist = new List<User>();
          pollinatorlist = [Select Id, Name FROM User ];
          options.add(new SelectOption('--None--','--None--'));
          for (User users : [SELECT Id, Name FROM User WHERE Profile.Name = 'Pollinators' AND IsActive = TRUE ORDER BY Name ASC])
              {
                  options.add(new selectOption(users.Id, users.Name));
              }
      return options;
        }
    public string pollinatorurl{get;set;}
        public PageReference processLinkClick() {
        return new PageReference('/00O90000005uwmQ?pv1='+pollinatorurl);
    }
}
  • March 24, 2014
  • Like
  • 0
Hi,

I have created a visualforce email template that contains a .ics calendar invite attachment. The attachment works fine for desktop/phone apps. But Gmail (using the web interface) will not recognise the .ics file and give the "Add to Calendar" option in the message. 

What I want is for the attached invite to appear in the email as so:
User-added image
Instead, it just appears as a regular attachment, with the only option being to download it.

I have created a calendar event in google calendar, downloaded it and emailed it to myself, and it works as per the image above. However, I put the exact same code in my VF template and send a test, and the invite doesn't work as above.

Here is my vf code (note that there are no merge fields in the invite code because I'm simply trying to get a basic invite to work). Can anyone see where I am going wrong? Thanks
 
<messaging:emailTemplate subject="Leave Request Approved" recipientType="User" relatedToType="Leave_Request__c">
<messaging:htmlEmailBody >
<html>

<style type="text/css">
...my styling...
</style>

<body>
 
...my body content...

</body>
</html>
</messaging:htmlEmailBody>
 
<messaging:attachment filename="reminder.ics">
BEGIN:VCALENDAR
VERSION:2.0
CALSCALE:GREGORIAN
BEGIN:VEVENT
STATUS:CONFIRMED
CREATED:20150507T054355Z
UID:qjvkvr7gsf10erbp9vc2fk05ec@google.com
DTEND;VALUE=DATE:20150510
TRANSP:TRANSPARENT
SUMMARY:Test Summary
DTSTART;VALUE=DATE:20150508
DTSTAMP:20150507T054355Z
LAST-MODIFIED:20150507T054355Z
SEQUENCE:0
DESCRIPTION:Test Description
END:VEVENT
END:VCALENDAR
</messaging:attachment>
 
</messaging:emailTemplate>

 
  • May 07, 2015
  • Like
  • 1
So I have created flows before where the flow is started from a record using a custom button, and that record's ID is passed into the flow as a variable, which is great!

However, I now want to do this but starting from a list view, where I would select (check) a bunch of records and then click a custom button to start the flow, and have the record IDs of all the checked records pass into the flow as a list of variables (I think it would be an sObject variable?)

Is this possible? 
Thanks
  • February 20, 2015
  • Like
  • 3
I am using the apex:map component in a Visualforce page. I can successfully render a map using coordinates pulled through an apex class.

However, the resulting location on the Visualforce page is slightly different to that shown if I put the same coordinates directly into Google Maps. (See maps below)

Does anyone know why this is happening?

VF page map code
 
<!-- Display the address on a map -->
        <apex:map width="600px" height="400px" mapType="roadmap" zoomLevel="17" center="{!program.Location__r.LatitudeTEXT__c},{!program.Location__r.LongitudeTEXT__c}">
            <apex:mapMarker title="" position="{!program.Location__r.LatitudeTEXT__c},{!program.Location__r.LongitudeTEXT__c}"/>
        </apex:map>

Visualforce Page Map
(you can see the coordinates returned from the apex class just above the map - these are what the map is using.)

User-added image

Google Map
(notice coordinates are the same as the VF page, but pin location is different)

User-added image
  • May 13, 2015
  • Like
  • 0
Hi,

I'm trying to change the background colour of a DIV on a VF page based on the value of a field. Since I have multiple options, it seems the best way to do this is to use the CASE function. However, I can't seem to get it to work. 

I have the follwing code:
<div class="programstatus" style="background-color:{!CASE(program.Program_Status__c == 'Applications Open', '#67AC34', program.Program_Status__c == 'Applications Closed' , '#F12923' )}">
                <apex:outputText value="{!program.Program_Status__c}"></apex:outputText>
                </div>

However, when I try to save, I get the following error: Error: Incorrect argument type for function 'CASE()'.

Any idea I'm doing wrong?
Thanks
  • April 26, 2015
  • Like
  • 0
Hi, I'm struggling to get a test class to work. Any help would be much appreciated!

Where I'm stuck is with the apex page parameter. In the test class I am trying to define this parameter and then pass it into the class (the last section of the test class). But I am totally stuck on how to get this to work.

Apex Class
public class InterviewsListDataTable {
    String Id = ApexPages.currentPage().getParameters().get('Id');
    public List<Interview_Time_Slot__c> interviewList {
        get {
            if (interviewList == null) {
                interviewList = [SELECT Interviewer_Name__c, Date_and_Time_of_Slot__c, Interviewer_Email__c, Interviewer_Skype_Name__c, Program__r.Program_Public_Name__c FROM Interview_Time_Slot__c WHERE Program__c =: Id ORDER BY Date_and_Time_of_Slot__c Asc];
            }
            return interviewList;
        }
        set;
    }
}

Test Class (work in progress)
@isTest
 private class TestInterviewsListDataTable {static testMethod void myUnitTest() {Profile pf = [Select Id from Profile where Name = 'System Administrator'];User u = new User();
 u.FirstName = 'Test';
 u.LastName = 'User';
 u.Email = 'testuser@test123456789.com';
 u.CompanyName = 'test.com';
 u.Title = 'Test User';
 u.Username = 'testuser@test123456789.com';
 u.Alias = 'testuser';
 u.CommunityNickname = 'Test User';
 u.TimeZoneSidKey = 'America/Mexico_City';
 u.LocaleSidKey = 'en_US';
 u.EmailEncodingKey = 'ISO-8859-1';
 u.ProfileId = pf.Id;
 u.LanguageLocaleKey = 'en_US';
 insert u;
system.runAs(u){


//Set RecordTypeId variable CA
 String strpRecordTypeId = [Select Id From RecordType WHERE DeveloperName = 'Fellowship' AND sobjectType = 'Program__c'].Id;

    
    Program__c program = new Program__c();
    program.Name = 'TestProgram';
    program.RecordTypeId = strpRecordTypeId;
    Insert program;
    
        Interview_Time_Slot__c objInterviewSlot = new Interview_Time_Slot__c();
        objInterviewSlot.Program__c = program.Id;
        Insert objInterviewSlot;
        
     
     PageReference PageRef = Page.Interviews;
     Test.setCurrentPage(PageRef);
     ApexPages.currentPage().getParameters().put('Id', 'program.Id'); 

     InterviewsListDataTable testlist = new InterviewsListDataTable();
     testlist.Id = program.Id;
     
     testlist.interviewList();

    }
}
}

 
  • April 21, 2015
  • Like
  • 0
So I have created flows before where the flow is started from a record using a custom button, and that record's ID is passed into the flow as a variable, which is great!

However, I now want to do this but starting from a list view, where I would select (check) a bunch of records and then click a custom button to start the flow, and have the record IDs of all the checked records pass into the flow as a list of variables (I think it would be an sObject variable?)

Is this possible? 
Thanks
  • February 20, 2015
  • Like
  • 3
Hi, I have written a test class that keeps failing because of a FIELD_FILTER_VALIDATION_EXCEPTION. I have narrowed it down to the exact problem: Part of a lookup filter (that is looking up a Cash Account) specifies that returned records must have their Status__c = 'Active' (see full lookup filter below). When I remove this part of the filter lookup logic, the test class passes. When I add it back in, the test class fails again.

As you can see in my test class below, I have definitely set the Status__c for the Cash Account record insert to be 'Active'. So I just can't figure out what I'm missing that is causing the test class to fail based on this.

Any help much appreciated.

Lookup Filter:
User-added image

Validation Error:
User-added image

Test Class:
@isTest
 private class TestCashAccountRollUpCashIn {static testMethod void myUnitTest() {Profile pf = [Select Id from Profile where Name = 'System Administrator'];User u = new User();
 u.FirstName = 'Test';
 u.LastName = 'User';
 u.Email = 'testuser@test123456789.com';
 u.CompanyName = 'test.com';
 u.Title = 'Test User';
 u.Username = 'testuser@test123456789.com';
 u.Alias = 'testuser';
 u.CommunityNickname = 'Test User';
 u.TimeZoneSidKey = 'America/Mexico_City';
 u.LocaleSidKey = 'en_US';
 u.EmailEncodingKey = 'ISO-8859-1';
 u.ProfileId = pf.Id;
 u.LanguageLocaleKey = 'en_US';
 insert u;
system.runAs(u){
//Set RecordTypeId variable CA
 String strcaRecordTypeId = [Select Id From RecordType WHERE DeveloperName = 'Person' AND sobjectType = 'Cash_Account__c'].Id;
//Insert a cash account 
 Cash_Account__c ca = new Cash_Account__c();
 ca.RecordTypeId = strcaRecordTypeId;
 ca.Name = 'Test Person';
 ca.Status__c = 'Active';
insert ca;
system.assertEquals(ca.Rollup_Cash_In__c, null);
//Set RecordTypeId variable CT
 String strctRecordTypeId = [Select Id From RecordType WHERE DeveloperName = 'Person_to_Person' AND sobjectType = 'Cash_Transfer__c'].Id;
//Test payments on insert
 Cash_Transfer__c ct1 = new Cash_Transfer__c();
 ct1.RecordTypeId = strctRecordTypeId;
 ct1.Destination__c = ca.Id;
 ct1.Amount__c = 100;
 insert ct1;
Cash_Account__c cau1 = [select Rollup_Cash_In__c from Cash_Account__c where Id = :ca.Id];
 system.assertEquals(cau1.Rollup_Cash_In__c,ct1.Amount__c);
//Test payments on update
 Cash_Transfer__c ct1u = [select Amount__c from Cash_Transfer__c where Id = :ct1.Id];
 ct1u.Amount__c = 200;
 update ct1u;
Cash_Account__c cau2 = [select Rollup_Cash_In__c from Cash_Account__c where Id = :ca.Id];
 system.assertEquals(cau2.Rollup_Cash_In__c,ct1u.Amount__c);
//Test payments on second insert
 Cash_Transfer__c ct2 = new Cash_Transfer__c();
 ct2.RecordTypeId = strctRecordTypeId;
 ct2.Destination__c = ca.Id;
 ct2.Amount__c = 800;
 insert ct2;
AggregateResult ag1 = [select sum(Amount__c) from Cash_Transfer__c where Destination__c = :ca.Id];
Cash_Account__c cau3 = [select Rollup_Cash_In__c from Cash_Account__c where Id = :ca.Id];
 system.assertEquals(cau3.Rollup_Cash_In__c,ag1.get('expr0'));
//Test payment on delete
 delete ct2;
AggregateResult ag2 = [select sum(Amount__c) from Cash_Transfer__c where Destination__c = :ca.Id];
Cash_Account__c cau4 = [select Rollup_Cash_In__c from Cash_Account__c where Id = :ca.Id];
 system.assertEquals(cau4.Rollup_Cash_In__c,ag2.get('expr0'));
}
}
}

 
  • February 17, 2015
  • Like
  • 0
Hi,

I currently have a SOQL query to populate a dynamic picklist (see below). Notice that I am already filtering the list results based on the city of the current user matching that of the users returned by the query. 

Id Mgrid = [select Id,ManagerId from User where id =: userinfo.getuserid()].ManagerId;
string MgrCity = [select City from User where id =: Mgrid].city;

list<user> u = new list<user>();
u = [SELECT Id, Name FROM User WHERE City =: MgrCity AND Profile.Name = 'Pollinators' AND IsActive = TRUE ORDER BY Name ASC];

The purpose of this is so different city managers can see a list of only their team members. However, I want people above city managers (eg the admin) to see the same list but without the City condition.

Any idea how to do that?
Thanks
  • January 26, 2015
  • Like
  • 0
Hi,

I currently have an SOQL query that gets a list of users who are of a specific profile and are active, which looks like this:
[SELECT Id, Name FROM User WHERE Profile.Name = 'Pollinators' AND IsActive = TRUE ORDER BY Name ASC]

This list is used to populate a dynamic picklist that managers user to access filtered reports. However, my business is expanding into new cities and so I want to also filter this list by showing only users who are in the same city as the manager.

I figured the best way to do this is to match the City field value on the User's record page. Upon doing some reading, I found a list of UserInfo Methods, and I can't see anything in there for City.

Can anyone help with how I might acheive this?
Thanks
 
  • January 21, 2015
  • Like
  • 0
Hi,
I have a visualforce email template for purchase orders. The email is sent using a workflow.
When I (an admin) test this template, it works fine. However, when another user (not admin) uses the template, the email is sent but the subject and body are blank.
Any ideas as to why this might be?
Thanks
  • May 05, 2014
  • Like
  • 0
Hi,
I'm trying to pass a picklist value into a url, whcih then links to a report which is filtered based on that value. However, I'm getting an error when trying to save the VF page, which says Error: Unsupported attribute action in <apex:outputLink> in Special_Reports at line 10 column 75

VF Page Code:

<apex:page controller="dynamicpicklist" >
    <apex:form >
    <apex:sectionHeader title="Dynamic Picklist" subtitle="Reusable code"/>
        <apex:pageblock >
            <apex:pageBlockSection title="Dynamic picklist" columns="1">
                <apex:outputlabel value="Pollinator" for="values" />
                <apex:selectList value="{!pollinator}" size="1" id="values">
                    <apex:selectOptions value="{!pollinatornames}"/>
                </apex:selectList>
                <apex:outputLink id="link" action="{!processLinkClick}">Process Report</apex:outputLink>                                          
            </apex:pageblocksection>
        </apex:pageblock>
    </apex:form>
</apex:page>

Class:

public class dynamicpicklist
{
    public String pollinator{get; set;}

    public List<SelectOption> getpollinatornames()
        {
          List<SelectOption> options = new List<SelectOption>();
          List<User> pollinatorlist = new List<User>();
          pollinatorlist = [Select Id, Name FROM User ];
          options.add(new SelectOption('--None--','--None--'));
          for (User users : [SELECT Id, Name FROM User WHERE Profile.Name = 'Pollinators' AND IsActive = TRUE ORDER BY Name ASC])
              {
                  options.add(new selectOption(users.Id, users.Name));
              }
      return options;
        }
    public string pollinatorurl{get;set;}
        public PageReference processLinkClick() {
        return new PageReference('/00O90000005uwmQ?pv1='+pollinatorurl);
    }
}
  • March 24, 2014
  • Like
  • 0

Hi,

 

My requirement is to render a column based on changes made in a picklist present in another column. I have used dataTable.

Though the data is appearing the header value doesn't appear.

 

Could someone please suggest me.