• 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
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
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();

    }
}
}

 
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
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'));
}
}
}

 
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
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
 
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
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);
    }
}

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.