• vbs
  • SMARTIE
  • 855 Points
  • Member since 2013

  • Chatter
    Feed
  • 28
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 0
    Questions
  • 220
    Replies

I have a picklist that I am trying to generate from a class.  The idea is that when a user picks an item from the list that they will be redirected to the corresponding page.  When I use the code snippet below in a test page where the class is set as the "Controller=class" it works great.  However, when I add the class to another page as "extensions=class", the drop down list will not render any values.

 

Any ideas on how to get this to render properly.

 

Visualforce:

 

<apex:page standardController="Task" extensions="taskManagementRedirectPicklist" tabStyle="Task">
<apex:form >	
	<apex:pageBlock title="Selection Criteria">		
		
		<apex:pageBlockSection showHeader="false" title="Options" columns="3">
			<apex:pageBlockSectionItem >
				
				<apex:selectList value="{!picklistvalue}" size="1" >
			    	<Apex:selectOptions value="{!item}"/>
			    	<apex:actionSupport event="onchange" action="{!redirect}" />    
			    </apex:selectList>
			    		
			</apex:pageBlockSectionItem>
	    </apex:pageBlockSection>
	</apex:pageBlock>
</apex:form>
</apex:page>

 

Apex Class:

 

public with sharing class taskManagementRedirectPicklist {
	
	private ApexPages.StandardController controller;
	
	public taskManagementRedirectPicklist(ApexPages.StandardController stdController) {
      controller = stdController;
   }   
	
	public list<selectoption>item{get;set;}
	public string picklistvalue{get;set;}
	
	public taskManagementRedirectPicklist()
	{
	    item=new list<selectoption>();
	    item.add(new selectoption('myTasks','Tasks Assigned to Me'));
	    item.add(new selectoption('myDelegatedTasks','Tasks I Assigned to Others'));
	}
 
	public pagereference redirect()
	{
	     PageReference pageRef= new PageReference('/apex/'+picklistvalue);
	    pageRef.setredirect(true);
	    return pageRef;
	}

}

 

  • August 19, 2013
  • Like
  • 0

Hi,

 

I want to write the trigger which send the email notifications when the case is closed.

 

Can any one help for this?

 

 

Regards.,

R.Ambiga

Hi Friends ,

Can anyone help me in resolving this code .

Error: Compile Error: Method does not exist or incorrect signature: [String].day() at line 19 column 37

 

// memberBirthdayBatch:

global class memberBirthdayBatch implements Database.batchable<Member__c>
{
global Iterable<Member__c> start(Database.batchableContext info)
{
System.debug('Start method');
return new callMemberIterable();
}
global void execute(Database.batchableContext info, List<Member__c> scope)
{
List<Member__c> memsToUpdate = new List<Member__c>();
System.debug('Member list size is ' + scope.size());
for(Member__c m : scope)
{
Date myDate = date.today();
Integer todayDy = myDate.day();
Integer todayMon = myDate.month();
System.debug('Day is ' + m.BirthDay__c.day());
Integer dy = m.BirthDay__c.day();
Integer mon = m.BirthDay__c.month();
if(todayDy == dy && todayMon == mon)
{
Messaging.SingleEmailMessage email = new Messaging.SingleEmailMessage();
List<String> toAddresses = new List<String>();
toAddresses.add(m.EmailAddress__c);
email.setToAddresses(toAddresses);
List<String> ccAddresses = new List<String>();
ccAddresses.add('salesforcecrm@gmail.com');
email.setCcAddresses(ccAddresses);
email.setSubject('Happy Birthday. Have a blast -- Birthday Reminder!');
String message = '<html><table cellspacing = "7"><tr><td style="font-weight:bold;color:green;">Happy Birthday!!!</td></tr><tr><td style="font-weight:bold;color:pink;">Many more Happy returns of the day.</td></tr><tr><td></td></tr><tr><td></td></tr><tr><td style="font-weight:bold;">Cheers,</td></tr><tr><td style="font-weight:bold;">XYZ</td></tr></table></html>';
email.setHtmlBody(message);
Messaging.sendEmail(new Messaging.SingleEmailMessage[]{email});
}
}
}
global void finish(Database.batchableContext info)
{
}
}

 

Thanks in advance

 

  • August 17, 2013
  • Like
  • 0

I'm trying to limit a previously working trigger by the RecordType Name.  I have tried adding my limiter to both the beginning For and the latter For and it doesn't seem to make a difference.  I've tried using both 'High School' and High_School' but that makes no difference.  If I say != then the trigger always fires and if I say == then the trigger never fires.  I must be doing something simple wrong but I just can't figure out what it is.  Any help would be greatly appreciated.

 

Thanks

Amanda

 

trigger OpportunityOwnerUpdate on Opportunity (before insert,before update) {
// gather all the Account Id's in a set

Set<Id> setAccountIds = new Set<Id>();

Opportunity[] opp = Trigger.new;
for (Opportunity o:opp)
{
if(o.Recordtype.Name != 'High School')

{
setAccountIds.add(o.AccountId);

}}

if( setAccountIds.size() > 0 ) // if there are no eligible Quote records, end
{
// store each Account Id with it's owner Id in a map, such that AccountId => Account.OwnerId

Map<Id, Id> mapAccountToOwner = new Map<Id, Id>();

for(Account a : [Select Id, OwnerId From Account Where Id IN : setAccountIds])

{

mapAccountToOwner.put(a.Id, a.OwnerId);
}
for (Opportunity o:opp)
{
if(o.AccountId !=null)
{
o.OwnerID = mapAccountToOwner.get(o.AccountId); // here you are avoiding the query
}
}
}}

Greetings,

 

I can't seem to figure out why I am getting the following error.  I have the "Name" field in my test class and have confirmed it is not NULL using system.assertvalue.  What am I doing wrong?  Thank you in advance for your help!!!

 

 

Error Message:::::::: System.DmlException: Insert failed. First exception on row 0; first error: REQUIRED_FIELD_MISSING, Required fields are missing: [Name]: [Name]

Stack Trace::::::   Class.multirecords.save: line 20, column 1
                              Class.TestMultiRecords.TestMultiRecords: line 36, column 1

 

 

 

 

 

*************************************************************************TEST CLASS******************************************************

 

 

@istest
public class TestMultiRecords{
    
    public static testMethod void TestMultiRecords(){
    date mydate = date.today();
    string accountnametest = 'TestMultiRec';
    string opportunitynametest = 'testOpp';
    string firstnametest = 'John';
    string lastnametest = 'Doe';
        
        PageReference pageRef = Page.multirecords;
        Test.setCurrentPage(pageRef);
        
        multirecords Controller = new multirecords();
        
        account a = new account(Name = 'TestMultiRec',phone='4109011267',macro_industry__c='Construction',custom_account_source__c='Referral',preferred_mode_s__c='Van');
        insert a;
        system.assertequals(accountnametest, a.name);
        
        contact c = new contact(accountid=a.id,firstname='John',lastname='Doe');
        insert c;
        system.assertequals(firstnametest, c.firstname);
        system.assertequals(lastnametest, c.lastname);
        
        task t = new task(whoid=c.id,subject='Email',whatid=a.id,priority='Normal',Status='Not started');
        insert t;
        system.assertequals(c.id,t.whoid);
        
        opportunity o = new opportunity(accountid=a.id,name='testOpp',stagename='Discovered',closedate=mydate);
        insert o;
        system.assertequals(opportunitynametest,o.name);
           
        controller.getaccountlist();
        controller.getcontactlist();        
        controller.cancel();
        controller.save();          //Error here
        
    }
}

 

 

 

*****************************************************************Controller**********************************************************************

 

public class multirecords {

public Account A {get; set;}
Public Task T {get; set;}
Public Opportunity O {get; set;}
string inputstring{get;set;}


public multirecords()
{
A = new account();
T = new task();
O = new opportunity();
}


public PageReference save()
{

insert a;


T.whatid = A.id;
insert T;

O.Accountid = A.id;
insert O;

/* Redirects the page to the new account
*/

return new PageReference('/'+A.id);
}

public PageReference Cancel()
{
return new PageReference('/001/o');
}

/* Used for the Account list at the end of the visualforce page.
*/
public List<Account> getAccountList() {
return [select name, Type FROM account WHERE Owner.id =: userinfo.getuserid() AND Type != 'Disqualified' AND Type != 'Recycle' ORDER BY Name];
}

/* Used for the Contact list at the end of the
VisualForce page
*/

public List<Contact> getContactList() {
return [select name, title, email, phone FROM contact WHERE owner.id =: userinfo.getuserid()];
}

}

 

|[17]|MAP<String,String>.get(Object)
23:12:36.034 (34396000)|SYSTEM_METHOD_EXIT|[17]|MAP<String,String>.get(Object)
23:12:36.034 (34406000)|VARIABLE_SCOPE_BEGIN|[17]|q_fulfillment|String|false|false
23:12:36.034 (34415000)|VARIABLE_ASSIGNMENT|[17]|q_fulfillment|null
23:12:36.034 (34419000)|STATEMENT_EXECUTE|[19]
23:12:36.034 (34422000)|STATEMENT_EXECUTE|[20]
23:12:36.034 (34425000)|STATEMENT_EXECUTE|[22]
23:12:36.034 (34427000)|LIMIT_USAGE|[22]|SCRIPT_STATEMENTS|13|200000
23:12:36.034 (34433000)|HEAP_ALLOCATE|[22]|Bytes:81
23:12:36.034 (34444000)|HEAP_ALLOCATE|[22]|Bytes:4
23:12:36.034 (34455000)|HEAP_ALLOCATE|[22]|Bytes:7
23:12:36.043 (43288000)|SOQL_EXECUTE_BEGIN|[22]|Aggregations:0|select Id, Email, FirstName, LastName from Contact where Email = :tmpVar1 limit 1
23:12:36.043 (43302000)|LIMIT_USAGE|[22]|SOQL|1|100
23:12:36.043 (43306000)|LIMIT_USAGE|[22]|AGGS|0|300
23:12:36.049 (49713000)|SOQL_EXECUTE_END|[22]|Rows:1
23:12:36.049 (49730000)|LIMIT_USAGE|[22]|SOQL_ROWS|1|50000
23:12:36.049 (49745000)|HEAP_ALLOCATE|[22]|Bytes:8
23:12:36.049 (49765000)|HEAP_ALLOCATE|[22]|Bytes:103
23:12:36.049 (49937000)|HEAP_ALLOCATE|[22]|Bytes:8
23:12:36.049 (49958000)|HEAP_ALLOCATE|[22]|Bytes:33
23:12:36.050 (50034000)|HEAP_ALLOCATE|[22]|Bytes:20
23:12:36.050 (50049000)|VARIABLE_SCOPE_BEGIN|[22]|attendee|Contact|true|false
23:12:36.050 (50090000)|VARIABLE_ASSIGNMENT|[22]|attendee|{"serId":1,"value":{"Email":"hucas.m@e (13 more) ...","FirstName":"hucas","Id":"003K000000dWxT3IAK","LastName":"M"}}|0x11362c1f
23:12:36.050 (50099000)|STATEMENT_EXECUTE|[23]
23:12:36.050 (50103000)|LIMIT_USAGE|[23]|SCRIPT_STATEMENTS|14|200000
23:12:36.050 (50109000)|HEAP_ALLOCATE|[23]|Bytes:47
23:12:36.050 (50120000)|HEAP_ALLOCATE|[23]|Bytes:4
23:12:36.052 (52617000)|SOQL_EXECUTE_BEGIN|[23]|Aggregations:0|select Id from User where Id = :tmpVar1 limit 1
23:12:36.052 (52630000)|LIMIT_USAGE|[23]|SOQL|2|100
23:12:36.052 (52635000)|LIMIT_USAGE|[23]|AGGS|0|300
23:12:36.054 (54488000)|SOQL_EXECUTE_END|[23]|Rows:0
23:12:36.054 (54504000)|LIMIT_USAGE|[23]|SOQL_ROWS|1|50000
23:12:36.054 (54516000)|HEAP_ALLOCATE|[23]|Bytes:4
23:12:36.054 (54526000)|HEAP_ALLOCATE|[23]|Bytes:0
23:12:36.054 (54604000)|HEAP_ALLOCATE|[23]|Bytes:4
23:12:36.054 (54617000)|HEAP_ALLOCATE|[23]|Bytes:30
23:12:36.054 (54708000)|HEAP_ALLOCATE|[23]|Bytes:46
23:12:36.054 (54745000)|VARIABLE_SCOPE_BEGIN|[56]|e|Exception|true|false
23:12:36.055 (55004000)|VARIABLE_ASSIGNMENT|[56]|e|"common.apex.runtime.impl.ExecutionException: List has no rows for assignment to SObject"|0x2e5f1556
23:12:36.055 (55017000)|STATEMENT_EXECUTE|[56]
23:12:36.055 (55021000)|STATEMENT_EXECUTE|[57]
23:12:36.055 (55024000)|LIMIT_USAGE|[57]|SCRIPT_STATEMENTS|15|200000
23:12:36.055 (55031000)|HEAP_ALLOCATE|[57]|Bytes:5
23:12:36.664 (56368000)|CUMULATIVE_LIMIT_USAGE
23:12:36.664|LIMIT_USAGE_FOR_NS|(default)|
  Number of SOQL queries: 2 out of 100
  Number of query rows: 1 out of 50000
  Number of SOSL queries: 0 out of 20
  Number of DML statements: 0 out of 150
  Number of DML rows: 0 out of 10000
  Number of code statements: 15 out of 200000
  Maximum heap size: 0 out of 6000000
  Number of callouts: 0 out of 10
  Number of Email Invocations: 0 out of 10
  Number of fields describes: 0 out of 100
  Number of record type describes: 0 out of 100
  Number of child relationships describes: 0 out of 100
  Number of picklist describes: 0 out of 100
  Number of future calls: 0 out of 10

23:12:36.664|TOTAL_EMAIL_RECIPIENTS_QUEUED|0
23:12:36.664|STATIC_VARIABLE_LIST|
  double:MIN_NORMAL:0
  double:POSITIVE_INFINITY:0
  long:serialVersionUID:0
  Boolean:TRUE:0
  double:MIN_VALUE:0
  int:SIZE:0
  int[]:sizeTable:0
  char[]:DigitOnes:0
  char[]:DigitTens:0
  double:NaN:0
  String:_sfdcAdditionalTypeInfo:0
  String:_sfdcAdditionalCodeLocations:0
  String:_sfdcAdditionalTypeInfo:0
  String:_sfdcAdditionalTypeInfo:0
  double:NEGATIVE_INFINITY:0
  int:MIN_VALUE:0
  int:SIZE:0
  String:_sfdcAdditionalCodeLocations:0
  String:_sfdcAdditionalCodeLocations:0
  double:MAX_VALUE:0
  long:serialVersionUID:0
  int:MAX_EXPONENT:0
  int:MIN_EXPONENT:0
  String:_sfdcAdditionalCodeLocations:0
  Boolean:FALSE:0
  int:MAX_VALUE:0
  char[]:digits:0
  long:serialVersionUID:0

23:12:36.664|CUMULATIVE_LIMIT_USAGE_END

23:12:36.670|CUMULATIVE_PROFILING_BEGIN
23:12:36.670|CUMULATIVE_PROFILING|SOQL operations|
Class.TTradeService.doGet: line 22, column 1: [ SELECT Id, Email, FirstName, LastName FROM Contact WHERE Email = :attendee_email LIMIT 1]: executed 1 time in 15 ms
Class.TTradeService.doGet: line 23, column 1: [SELECT Id FROM User WHERE Id = :customField1 LIMIT 1]: executed 1 time in 4 ms

23:12:36.670|CUMULATIVE_PROFILING|No profiling information for SOSL operations
23:12:36.670|CUMULATIVE_PROFILING|No profiling information for DML operations
23:12:36.670|CUMULATIVE_PROFILING|method invocations|External entry point: global static String doGet(): executed 1 time in 22 ms
Class.TTradeService.doGet: line 7, column 1: global String __sfdc_remoteAddress(): executed 1 time in 0 ms
Class.TTradeService.doGet: line 8, column 1: global Blob __sfdc_requestBody(): executed 1 time in 0 ms
Class.TTradeService.doGet: line 9, column 1: global String __sfdc_requestURI(): executed 2 times in 0 ms
Class.TTradeService.doGet: line 10, column 1: global MAP<String,String> __sfdc_params(): executed 1 time in 0 ms
Class.TTradeService.doGet: line 12, column 1: global MAP<String,String> __sfdc_params(): executed 2 times in 0 ms
Class.TTradeService.doGet: line 13, column 1: global MAP<String,String> __sfdc_params(): executed 2 times in 0 ms
Class.TTradeService.doGet: line 14, column 1: global MAP<String,String> __sfdc_params(): executed 2 times in 0 ms
Class.TTradeService.doGet: line 15, column 1: global MAP<String,String> __sfdc_params(): executed 2 times in 0 ms
Class.TTradeService.doGet: line 17, column 1: global MAP<String,String> __sfdc_params(): executed 2 times in 0 ms
Class.TTradeService.doGet: line 16, column 1: global MAP<String,String> __sfdc_params(): executed 2 times in 0 ms

23:12:36.670|CUMULATIVE_PROFILING_END
23:12:36.056 (56571000)|CODE_UNIT_FINISHED|TTradeService.doGet
23:12:36.056 (56583000)|EXECUTION_FINISHED
@RestResource(urlMapping='/ttradeservice')
global class TTradeService {
    @HttpGet
    global static string doGet() {
        RestRequest req = RestContext.request;
        RestResponse res = RestContext.response;
        String remoteAdd = RestContext.request.remoteAddress;
        Blob reqBody = RestContext.request.requestBody;
        String answerId = req.requestURI.substring(req.requestURI.lastIndexOf('/')+1);
         Map <String, String> reqParams = RestContext.request.params;
     
        String first_name = RestContext.request.params.get('attendee_person_firstName');
        String last_Name = RestContext.request.params.get('attendee_person_lastName');
        String customField0 = RestContext.request.params.get('attendee_customField0');
        String attendee_email = RestContext.request.params.get('attendee_email');
        String customField1 = RestContext.request.params.get('attendee_customField1');
        String q_fulfillment = RestContext.request.params.get('questionId__fulfillment');

        try 
        { 
            Contact attendee = [ SELECT Id, Email, FirstName, LastName FROM Contact WHERE Email = :attendee_email LIMIT 1];
            User CSA = [SELECT Id FROM User WHERE Id = :customField1 LIMIT 1];
            List<ts2__Assessment__c> assmnts = [SELECT ts2__User__c, TimeTrade_Event_ID__c, Location__c, Campus__c, Appointment_Type__c,Date__c,Details__c,End_Time__c,Start_Time__c,ts2__Contact__c FROM ts2__Assessment__c WHERE Id = :attendee.Id LIMIT 1];
            
            if (assmnts.size() > 0)
            {
                return 'no error1';
            }
            else if (attendee.Id != '' ) 
            {         
                ts2__Assessment__c newassmnt = new ts2__Assessment__c();
                
                newassmnt.ts2__Contact__c = customField0 ;
        //        newassmnt.Appointment_Type__c = 
        //        newassmnt.Date__c = 
        //        newassmnt.Start_Time__c = 
        //        newassmnt.End_Time__c = 
        //        newassmnt.Details__c = 
        //        newassmnt.TimeTrade_Event_ID__c = 
        //        newassmnt.Location__c = 
        //        newassmnt.Campus__c = 
                newassmnt.ts2__User__c = CSA.Id;
                insert newassmnt;
                return 'no error2';
            }
            
            else
            {
               return 'Hello '+first_name;
            }
        } 
        catch (exception e) 
        {
            return 'error';
        }
    }
}

 Hi there,

 

Can someone help me to debug the issue here?

 

I am trying to build rest API process. where the thirdparty application is trying to some info into our org with out authenitcation. I have exposed the apex class using public access setting on a force.com site and calling this class through that.

 

I can see that I can do a proper handshake but I get 'error' from the exception. May I know whats causing it to avoid try section of the code?

 

Thank you,

Manohar

We plan to do data migration one siebel crm  to salesforce, does anyone know if org data and positions data which mean a lot in siebel need to be migrated for records to show?

 

thanks

Hello,

 

I am new to the developer forums. I am not sure if this is the correct section to post this in, so please forgive me if this post is miscategorized.

 

I work for a non-profit ethnic media organization. We are currently using a very outdated and poorly-built CRM that also includes an ethnic media directory. We use the CRM to keep records of all of our partner media outlets and their associated contacts. We sell subscriptions to the ethnic media directory on our website.

 

The ethnic media directory grants subscribers read-only access to view certain records in the CRM (ethnic media outlets and their associated contacts). Directory subscribers register for an account through our website and are able to log in to the directory using that account through a web-based portal which is separate from our internal CRM login page.

 

We recently began building a new CRM using SalesForce. Our goal is to switch over from our old CRM to SalesForce. We have imported all of our records from the old system and are pretty much finished setting up the new CRM, but we have not yet built a replacement for our old ethnic media directory. I am curious to know if anyone has any suggestions on how to go about doing this.

 

I've read a few things about VisualForce and Apex, and I am curious to know if I could use these to build a new ethnic media directory that grants subscribers a form of limited access to certain records in our SalesForce org. The system would need to be able to handle registering and authenticating subscribers, providing read-only access to certain records and so on through a web-based portal interface.

 

We are currently using a free non-profit edition of SalesForce, so we are limited to 10 user licenses. The ethnic media directory would ideally use a single "API/read-only user" account to access SalesForce. Ideally, I would like for the directory to reference the Contacts object for registering and authenticating subscribers, as we could have a special contact record type for subscribers with an encrypted field to store their password and a date field to store their subscription expiration date.

 

I'm fairly new to SalesForce in general and I have no prior experience working with VisualForce, Apex, etc. I'd like to know if there's a way to do this with VisualForce/Apex and if so, how do I go about building it? Will I need to use PHP instead? Please let me know.

 

Thanks for taking the time to read and respond to my post.

 

  • August 08, 2013
  • Like
  • 0

Hi Guys,

 

I am trying to test the below trigger, however am not able to reach the allowed coverage %70,

basically there three insert and one delete in the trigger, am able to get the first part covered however the second part after isUpdate doesn't get covered 

 

please see the code

trigger setAssignRec on Activity__c (after insert, before update) {
   
   
    List <Activity__Share> activityShared = new List <Activity__Share> ();
   
   //string CurrentUser =    UserInfo.getUserId();
 for (Activity__c act : trigger.new )
 {
         if (trigger.isInsert){
         List <Activity__Share> actShare1 = [SELECT Id, ParentId, UserOrGroupId, AccessLevel, RowCause, LastModifiedDate, LastModifiedById, IsDeleted 
                                             FROM Activity__Share
                                             where ParentId =: act.Id];
         for (integer i = 0; i < actShare1.size(); i++)
         {
             //actShare1.get(i).RowCause != 'Owner'
            // &&  the owner of the activity will be excluded from the share
         if (act.Assigned_To__c != actShare1.get(i).UserOrGroupId)
         {
    	Activity__Share actShare = new Activity__Share();
		actShare.ParentId = act.id;
		actShare.UserOrGroupId = act.Assigned_To__c;
		actShare.AccessLevel = 'Edit';
        actShare.RowCause = Schema.Activity__Share.RowCause.delegate__C ;
        activityShared.add (actShare);
          //}
         }
         }
         Database.SaveResult[] ActivityShareInsertResult = Database.insert(activityShared,false);
     }
    
    //insert activityShared;
       
    
    if (trigger.isUpdate)
    { 
            List <Activity__Share> actShareDel = new List <Activity__Share>() ;
            List <Activity__Share> actShareIns = new List <Activity__Share>() ;
            
            
           List <Activity__Share> actShare2 = [SELECT Id, ParentId, UserOrGroupId, AccessLevel, RowCause, LastModifiedDate, 
                                               LastModifiedById, IsDeleted 
                                               FROM Activity__Share
                                               where ParentId =: act.Id ];
       
               // inset the new assigned employee
                  for (integer y =0 ; y < actShare2.size(); y++)
                  {
                      
                     if (actShare2.get(y).UserOrGroupId == act.Assigned_To__c  && actShare2.get(y).RowCause == 'delegate__c') 
                     {
                        continue;
                     }  
                    else if (actShare2.get(y).UserOrGroupId != act.Assigned_To__c )
                    {
                         Activity__Share actSharetab = new Activity__Share();
					 	 actSharetab.ParentId = act.id;
					 	 actSharetab.UserOrGroupId = act.Assigned_To__c;
					 	 actSharetab.AccessLevel = 'Edit';
        		    	 actSharetab.RowCause = Schema.Activity__Share.RowCause.delegate__C ;
						 actShareIns.add (actSharetab);
                    }
                   
//if( actShare2.get(y).UserOrGroupId == act.Assigned_To__c && actShare2.get(y).RowCause != 'Owner')
             	 }
                // Database.SaveResult[] ActivityShareInsert = Database.insert(actShareIns,false); 
				insert actShareIns;
            
// delete the unassigned employee
        		for (Activity__c actOld: trigger.old)
            		{
               		for (integer i = 0; i < actShare2.size(); i++)
                //for (Activity__Share actItem : actShare)
                		{	
                // getting the recod of the ones who used to have an honorship but 
                // they have been changed to the new owner and exlucding the orginal owner
                			if (actShare2.get(i).UserOrGroupId == actOld.Assigned_To__c && actShare2.get(i).UserOrGroupId != act.Assigned_To__c && actShare2.get(i).RowCause !='Owner' )
           					{
               				 actShareDel.add (actShare2.get(i));
                			}
                         
              	  		}
                 		delete actShareDel;		
            		} 
        system.debug ('delete test' +  actShareDel);
        
    } 
  }
}

 

 

And wrote the below test class, please note I have not made assertion for the delete however I already tried but the code coverage not changed, 

 

 

@isTest //(SeeAllData = true) 
public class TestAssignedToShare {
   
     static testMethod void testAssignedTo()
    {
        
  	 Profile p = [SELECT Id FROM Profile WHERE Name='System Administrator']; 
      User u = new User(Alias = 'closenet', Email='AdminClosenet@testorg.com', 
      EmailEncodingKey='UTF-8', LastName='closenet', LanguageLocaleKey='en_US', 
      LocaleSidKey='en_US', ProfileId = p.Id, 
      TimeZoneSidKey='America/Los_Angeles', UserName='closenet.tester@gmail.com');
        
          
        System.runAs(u)
          {
             
        ActivityType__c  actType =  new  ActivityType__c (
            								  OwnerId = '005i0000000fDLHAA2',
            								  Name = 'My test');
        insert actType;  
          system.debug ('xxxx'+ actType);					
         List  <ActivityType__c> actTypeLst = [SELECT Id, OwnerId, IsDeleted, Name
              							       FROM ActivityType__c 
                                               where Id =: actType.id ];
            								
         Activity__c  act = new Activity__c  (
                                            
                                             Assigned_To__c= '005i0000000fDLHAA2', 
                                             Completed_Date__c= null, 
                                             ActivityTypeId__c = actTypeLst.get(0).Id,
                                             Completed__c= false ,
                                             Cancelled__c= false ,
                                             Required_Date__c = Datetime.now() ,
                                             Cancelled_Date__c = null
         									 );
              

              								/*
      									  act.Assigned_To__c= '005i0000000fDLHAA2';
                                          act.completed_Date__c= null;
                                          act.ActivityTypeId__c = 'a07i0000001ymKH';
                                          act.Completed__c= false ;
                                          act.Cancelled__c= false ;
                                          act.Required_Date__c = Datetime.now() ;
                                          act.Cancelled_Date__c = null;
              								*/
                                        
     insert act;
     List <Activity__c> activityLst =  [SELECT  Id, IsDeleted, Name, CreatedDate, CreatedById, LastModifiedDate,
                                    LastModifiedById, SystemModstamp,LastActivityDate, Assigned_To__c,
        							Completed_Date__c,   Required_Date__c, Status__c 
                                    FROM Activity__c];
             
	//test
     system.assertEquals('005i0000000fDLHAA2',activityLst.get(0).Assigned_To__c );  
              
      
     Activity__Share actShare = new Activity__Share (ParentId = activityLst.get(0).id, 
                                                     UserOrGroupId = '005i0000000fDLHAA2', 
                                                     AccessLevel = 'Edit' ,
     												 RowCause = 'delegate__c');
              
    
     insert actShare;
  //  system.debug ('sharing insert ' + actShare ) ;           
              
    //Database.SaveResult sr = Database.insert(actShare,false);
     
              
     List <Activity__Share>  activitySharedLst = [SELECT Id, ParentId, UserOrGroupId, AccessLevel, 
                                                 RowCause, LastModifiedDate, LastModifiedById, IsDeleted
                                                 FROM Activity__Share 
                                                 where UserOrGroupId =: act.Assigned_To__c ];
              
      //test        
     system.assertEquals('delegate__c', activitySharedLst.get(0).RowCause );
       // system.debug ('before delete share' + activitySharedLst ) ; 
              
              List <Activity__Share> activitySharedLst_Del  =  new List  <Activity__Share> ();
              for (integer x = 0 ; x  < activitySharedLst.size() ; x++)
              {
                  if (activitySharedLst.get(0).RowCause == 'delegate__c')
                  	{
                     activitySharedLst_Del.add(activitySharedLst.get(x));
                  	}
                 
              } 
              delete activitySharedLst_Del; 
      
              
                  //List <Activity__Share>  activitySharedLst_Del = [SELECT Id, ParentId, UserOrGroupId, AccessLevel, 
                              //                   RowCause, LastModifiedDate, LastModifiedById, IsDeleted
                                 //                FROM Activity__Share where RowCause = : 'delegate__c' ];
             
                           
    
                
              system.debug ('after delete share' + activitySharedLst_Del ) ; 
      
              
          
     		//System.assertEquals (activitySharedLst.get(0).RowCause, 'Owner');
            
     //system.assertEquals('005i0000000fDLHAA2',activityLst.get(0).Assigned_To__c );  
           
              
              }
    }
}

 

 

Please help me to get increase the coverage to meet at least the minumum allowed

 

Thanks in advance

 

 

 

Hi all,

I am using salesforce api to pull data through a created connected app that was created through Build>Create>Apps.

 

On the other side (my custom application), looks like I am getting only 250 records where there should be much more. I have looked through most of documentation, but was unable to find place to regulate amount of rows returned per call.

 

Do you have any advice on where can I start to look for an answer?

Thank you,

Mario

Hello,

 

I'm a new user with a devil of a problem - I need to create a bit of code that wil allow me to send meeting requests to non-Salesforce users that will put my Salesforce meetings in their diaries, Outlook or other.

 

I put full details of my request on the General board, thinking it could be done from within the custom HTML email templates.  I now realise it's more of an Apex issue.  

 

Would you be so kind as to take a look?  The thread is http://boards.developerforce.com/t5/General-Development/sending-an-ICS-Outlook-compatible-calendar-request-with-workflow/td-p/658603.

 

Best regards,

 

Alex.

Hi,

 

I need get the values of custom fields from custom object using sObject.

I have tried with below code

 

Employee__c account = new Employee__c();

       Map<String, Schema.SObjectType> sobjectSchemaMap = Schema.getGlobalDescribe();

           //The describeSObjects() call returns an array of DescribeSObjectResult objects.

           Schema.DescribeSObjectResult objDescribe = sobjectSchemaMap.get('Employee__c').getDescribe();

            Map<String, Schema.SObjectField> fieldMap = objDescribe.fields.getMap();   

       

             for(Schema.SObjectField fieldDef : fieldMap.values())

            {

                Schema.Describefieldresult fieldDescResult = fieldDef.getDescribe();

                String name = fieldDescResult.getName();

                System.debug(name);

                System.debug(account.get(name));

        }

 

here I m able to get the custom fileds but not values.

Plz suggest....

 

Thanks....

  • August 01, 2013
  • Like
  • 0

Hi all,

I am tring to develop an VF PAge which shows a list of books in pageblocktable.

Each row shows the data for a book record.

I want to get to the next page(the detail page) for the book selected by clicking on the command button in its row.

How to get that id of the selected book among all the idds in the table.

One idea is by using wrapper class but i am a newbie and don't know how to do this using that

Thanks in advance

  • August 01, 2013
  • Like
  • 0

I have a list of leads which i retrieve through query, now i want to convert this list of leads to account and contacts without using any trigger/validation. only through apex code.  Below is code on which i am working.

list<Lead> myLead = [select id,LastName,company from Lead where company='sambodhi'];
return myLead;
for(integer i=0; i<=mylead.size();i++){
Database.LeadConvert lc = new database.LeadConvert();
lc.setLeadId(myLead[i].id);
lc.setAccountid(myLead[i].id);
LeadStatus convertStatus = [SELECT Id, MasterLabel FROM LeadStatus WHERE IsConverted=true limit 199
ALL ROWS];
lc.setConvertedStatus(convertStatus.MasterLabel);
Database.LeadConvertResult lcr = Database.convertLead(lc);
System.assert(lcr.isSuccess());
}

I have a field within each account called: Allocated_Hours__c . This is a forumla which basically works out the number of hours each account gets. Within the User area I then have a field which displays the number of hours a user has in there month. What I want to be able to do is:

Add up the total number of hours a user has for their accounts and subtract that against the number of hours they have.

For example:

Peter has 14 accounts at 10 hours each = 140 hours. He gets allocated 150 hours so therefore he has 10 hours spare.

Any help would be much appreciated.

Hi, This is Rajesh, I have to create two dashboards dynamically and assign those two dashboards with two users.

Each user can able to see only one dashboard only. How can i acheive this.

 

Thanks & Regards.

Hi

I am new to test classes. I have made controller which contain only querries. I need help to make a test class of it.

what should be the approach?

 

///////////////////////controller///////////////////////////////////////

 

public with sharing class Bcaformatcontroller{

public String workstations { get; set; }
public date today{get;set;}
public String offerID = ApexPages.currentPage().getParameters().get('Id');
public List <RealSteer__LeaseOffer__c> records {get;set;}
public List<Contact> licenseeCon {get;set;}
public List<AccountContactRole> licenseeConID {get;set;}
public List<AccountContactRole> licensorConID {get;set;}
public List<Contact> licensorCon {get;set;}
public List<Services__c> charge{get; set;}
public List<Services__c> chargeParking{get; set;}
public String pdfURL{get;set;}

public Bcaformatcontroller(){
today = System.today();
records = [Select r.Deposit_ask_for__c, r.Start_Date__c, r.RealSteer__Property__r.Name,RealSteer__Property__r.RealSteer__Street__c,RealSteer__Property__r.RealSteer__City__c,
RealSteer__Property__r.RealSteer__State__c,RealSteer__Property__r.RealSteer__Country__c, Offer_Through__c, RealSteer__Property__r.Account__c,
r.RealSteer__Property__c, r.Name, r.Id, r.End_Date1__c, r.Duration__c,Company_Name__r.Name,r.RealSteer__Property__r.Total_L_Shaped__c, r.RealSteer__Property__r.Total_Linear__c,
r.Company_Name__c, Broker_Name__c,Company_Name__r.BillingCountry,Company_Name__r.BillingPostalCode,
Company_Name__r.BillingState,Company_Name__r.BillingCity,Company_Name__r.BillingStreet ,r.Lock_In_Period__c, r.Notice_Period__c
From RealSteer__LeaseOffer__c r where id = :offerID];

licenseeConID = [SELECT ContactId FROM AccountContactRole WHERE (IsPrimary =: true AND AccountId =: records[0].Company_Name__c)];
licenseeCon = [Select LastName,Phone,Fax, FirstName, Salutation From contact where id =: licenseeConID[0].ContactId ];

licensorConID = [SELECT ContactId FROM AccountContactRole WHERE (IsPrimary =: true AND AccountId =: records[0].RealSteer__Property__r.Account__c)];
licensorCon = [Select LastName,Phone,Fax, FirstName, Salutation From contact where id =: licensorConID[0].ContactId ];

charge = [Select Charges_Per_Hour__c from Services__c where (Business_Center_Name__c = :records[0].Company_Name__c AND RecordTypeid in(select id from recordtype where name = : 'Internet Services'))];
chargeParking = [Select Parking_Rate__c from Services__c where (Business_Center_Name__c = :records[0].Company_Name__c AND RecordTypeid in(select id from recordtype where name = : 'Parking'))];


}


}

 

Thanks

Ishan Sharma

Hello,

 

In the following javascript, i'm trying to 1.) Query a case 2.) Update a field based on a page parameter. When I try to update the case, salesforce is kicking back an error:

 

failed to update case {errors:{message:'sObject type 'sObject' is not supported. If you are attempting to use a custom object, be sure to append the '__c' after the entity name. Please reference your WSDL or the describe call for the appropriate names.', statusCode:'INVALID_TYPE', }, id:null, success:'false', }

 

Here is the code:

 

  	function chooseRep(id){
            var fieldName = '{!$CurrentPage.parameters.field}';
            
            sforce.connection.sessionId = '{!$Api.Session_ID}';
            var result = sforce.connection.query("SELECT id, Sales_Rep__c, NDS_Assigned__c FROM Case WHERE ID = \'{!$CurrentPage.parameters.id}\'");
            
            
            
            if(fieldName == 'SalesRep'){
                result.records.Sales_Rep__c = id;
            }else{
            	result.recoreds.NDS_Assigned__c = id;       
            }
            
            var result2 = sforce.connection.update([result.records.Id]);
            if (result2[0].getBoolean("success")) {
    			alert("case with id " + result2[0].id + " updated");
  			} else {
    			alert("failed to update case " + result2[0]);
  			}
            
            var previousCase = "{!$CurrentPage.parameters.id}";
            window.location.href = "/" + previousCase;
        }

I'm thinking I need to cast the "result" variable to a case, but i'm not exactly sure how to do that via the Ajax Toolkit.

 

Thanks! 

 

I only know how to create these via UI, and am having trouble finding this info on the internet.  Please and thanks

 

Needed for:  

1) Have multiple developer/sandbox orgs, and need to create custom settings in each using an apex script, vs manually via UI.

2) Test Method best practice:  to use custom settings you have to use the seeAllData=true, OR you have to create these Custom Settings in your test class.  Is that even possible and how do you do that? 

 

Also, let me clarify - I am asking not about instances of existing custom settings, but  how to create an actual new Custom Settings classes/types programmatically.

I cannot find the answer to my question in the boards, and I am very new to SF, so please be gentle with me!

 

I have used REST before, but not with SF, and I am just starting. I already have some reports defined in SF, and I want to run an Excel VBA script to download the results of these four reports into Excel (I will be doing this once a week).

 

The documentation I have been able to understand keeps talking about SQL. I understand SQL, but since the report is already defined to SF, surely there is a way to specify that's what I want? Or do I simply have to rewrite the extract using SQL?

 

Sorry again if this has already been asked, but I could not find it.

 

Thanks for listening.

  • July 29, 2013
  • Like
  • 0
Hi,

I have got a visualforce page, where I am showing in a table a list of cases I get from my Apex Class.

This is my visualforce:

<apex:page controller="XMLCasePopupController" title="Search" showHeader="false" sideBar="false" tabStyle="Case" id="page" >
  <!-- messages -->
  <apex:outputPanel id="top" layout="block">
    <apex:outputLabel value="Possible duplicates" style="margin:20px; padding:10px; margin-top:10px; font-weight:bold; font-size: 1.5em;"/>
  </apex:outputPanel>

  <apex:form >
  <apex:pageBlock title="XML Case Edit" id="XML_Case_Edit" mode="Edit">
      <!-- Buttons toolbar -->   
        <apex:pageBlockButtons >
            <apex:commandButton value="Finish" action="{!endCaseCreation}"/>
        <!--    <apex:commandButton value="Back" action="{!backStep}"/> -->
        </apex:PageBlockButtons>
      
        <apex:outputPanel id="page" layout="block" style="margin:5px;padding:10px;padding-top:2px;">
  <apex:actionRegion >
      <!-- results panel -->
      <apex:outputPanel id="pnlSearchResults" style="margin:10px;height:350px;overflow-Y:auto;" layout="block">
          <apex:pageBlock id="searchResults">
             <apex:pageBlockTable value="{!results}" var="c" id="tblResults">
                    <apex:column >
                    <apex:facet name="header">
                        <apex:outputPanel >Release</apex:outputPanel>
                    </apex:facet>
                    <apex:outputLink onClick="test('{!c.Id}');return false;">{!c.Module_Release__c}</apex:outputLink>
                    </apex:column>
</apex:column>
             </apex:pageBlockTable>
         </apex:pageBlock>
      </apex:outputPanel>
  </apex:actionRegion>
  </apex:outputPanel>
    </apex:pageBlock>
    <apex:actionFunction name="test" action="{!ShowCaseToTrue}">
        <apex:param name="param1" assignto="{!IdChosen}" value=""/>
    </apex:actionFunction>
  </apex:form>

So I am calling the actionFunction ShowCaseToTrue and I want to pass the Id of the case that the user has clicked in the table. This is my apex class:

public with sharing class XMLCasePopupController {


  public List<Case> results{get;set;} // search results
  public string searchString{get;set;} // search keyword
  public string caseId{get;set;}
  public Boolean ShowCase{get;set;}
  public Case ChosenCase{get;set;}
  public Id IdChosen{get;set;}

  public XMLCasePopupController() {
    // get the current search string
    searchString = System.currentPageReference().getParameters().get('lksrch');
    caseId = System.currentPageReference().getParameters().get('id');
    //ShowCase=False;
    System.debug('==> searchString = ' + searchString + ' -- caseid ' + caseId);
    runSearch();
  }

  // performs the keyword search
  public PageReference search() {
    runSearch();

    return null;
  }

  // performs the keyword search
  public void ShowCaseToTrue() {
    this.ShowCase=True;
    system.debug('El id que tengo que buscar es: '+ IdChosen);
    ChosenCase=[SELECT Id,CaseNumber FROM Case WHERE Id=:IdChosen];
  }
}

I am always getting a null value in IdChosen. Can anybody help me on what I am missing here?

Thanks a lot!

Antonio
The error is coming when i want to fetch customerUserTypes in Profile.

Set<String> customerUserTypes = new Set<String> {'CSPLiteUser', 'PowerPartner', 'PowerCustomerSuccess',   'CustomerSuccess'};
Account acc = new Account (
Name = 'newAcc1'
); 
insert acc;
Contact con = new Contact (
AccountId = acc.id,
LastName = 'portalTestUser'
);
insert con;
Profile p = [select Id,name from Profile where UserType in :customerUserTypes limit 1];

User newUser = new User(
profileId = p.id,
username = 'newUser@yahoo.com',
email = 'pb@ff.com',
emailencodingkey = 'UTF-8',
localesidkey = 'en_US',
languagelocalekey = 'en_US',
timezonesidkey = 'America/Los_Angeles',
alias='nuser',
lastname='lastname',
contactId = con.id
);
insert newUser;
Hi

Disclosure: not a developer..

I want to have a field update workflow start, but it is based on a formula field and it does not seem that a formula field can start a workflow.

Essentially, I have a formula field on Opportunities called Paid (Paid__c) and when this evaluates to True, I want the Stage (StageName) field to update to Closed Won.  I'd like this to happen in as near to real time as possible - every 15 min?  More frequent, if it wouldn't be problematic...

Is this something that is simple for someone that knows what they are doing or can someone point me in the right direction?
{!REQUIRESCRIPT("/soap/ajax/28.0/connection.js")}
{!REQUIRESCRIPT("/soap/ajax/25.0/apex.js")}

var retStr;
retStr = sforce.apex.execute("SF_Rockport", "callRockport",{ID:"!Transaction__c.Id}"});

alert('The method returned: ' + retStr);

User-added image

Hello,

 

I have two custom objects. There is a Master-Detail relationship between them.

 

I have created a Master record and a Child record & related this to created Master record.

 

I have created one more Master record. I need to change the Master now.

 

But when I tried to edit the child record, it is showing the related Master lookup field as only readable.

 

Is this a new feature in Winter '14?

 

Is there any other way to change this?

 

Please clarify ASAP.

 

 

Thanks,

Arunkumar

 

 

Hi,

 

I am trying to create a application that does data analytics of a Sales Force CRM user's contacts and leads. Basically I want to pull of the contacts and leads from the Salesforce CRM and send it via REST API to my server to do some analysis on the data. After the analysis is complete, I want to send the data back to the Salesforce CRM.

 

I heard that because Salesforce platform is a multi-tenant environment, there are limitations on how much CPU I can use at any one time. Is a cron job that sends the information over time the best approach? And also can anyone give me some pointers as to what code I need to write to achieve this? I am fairly new to the Salesforce platform but have a good understand of Apex.

 

thanks,

Nick

I have a pageBlockTable with inputcheckbox. I want to count the number of records selected and display the count in the ApexPages.message.

 

Any idea how I can do this? Thanks!!

 

 

VFP


<apex:pageBlockTable value="{!priceist}" var="p" id="results">

<apex:column >
<apex:inputCheckbox value="{!p.selected}" onchange="updateSelectCount(this);"/>
</apex:column>


<apex:column >
...
</apex:column>

</apex:pageBlockTable>
   
   
</apex:pageBlock>

 

//Apex class


 public PageReference approveRecord(){

 

    // my logic and finally


  ApexPages.addMessage(new ApexPages.message(ApexPages.severity.Confirm,'All records successfully approved!'));    // Here instead of 'All' i want {!count}

}

We have a custom button that executes JavaScript on our case record:

{!REQUIRESCRIPT("/soap/ajax/14.0/connection.js")}
{!REQUIRESCRIPT("/soap/ajax/14.0/apex.js")}
this.disabled=true;
try{
var accId='{!Account.Id}';
var objectId = '{!Case.Id}';

var result = sforce.apex.execute("ForceJiraComm", "createIssue",
{case_id : objectId});
alert(result);
location = location;
}
catch(err) {
txt="There was an error on this page.\n\n";
txt+="Error description: " + err + "\n\n";
txt+="Click OK to continue.\n\n";
alert(txt);
}
this.removeAttribute('disabled');

We want it to also write the full name of the user that clicked the button to the custom field JIRA_Escalated_By__c on the case object.  How do we do this?

Basically, how can update our APEX to store who clicks a custom button?”

L = Database.query('SELECT Id,Name (Select QualificationStatus__c From Qualifications__r where QualificationStatus__c =\'Success\' AND QualificationType__c=:countries) FROM Contact WHERE Firstname= :text');

 

 

Getting error

System.QueryException: unexpected token: 'Select'

 

 

 

 

 

String AppNumber = lastApp.Name
Map<String, String> value = new Map<String, String>();
  value.put('{#AppNumber}', AppNumber);

 Agreement template = new Agreementtemplate();
                template.init(lastProg.Thank_You_Page__c, lastProg.Id, 'Prog__c', value);

In Object__c I have a picklist field called Campaign__c and one of the picklist values is 2014 Charity Run.

 

In my Apex code, how can i avoid hardcoding the Campaign__c value ?

 

 

list <Object__c> obj = [Select id,name, Account__c, Campaign__c

                                   from Object__c

                                   Where Campaign__c=:'2014 Charity Run'];

 

 

 

Is custom setting the way to go?

 

 

 

 

 

 

 

 

 

 

Hello,

 

This Trigger is copying some fields from Accoun to IMP__C Custom Object. It's working fine.

 

There is a field on Account "IsClosed" (standard field) , it's a checkbox. I need to copy the value of this check box to IMP__c. Means when checkbox is true it should update value on IMP__C "closed" field as True. I am not sure how to write this in this trigger?

 

trigger insertfielddat on Account(after insert,after update) {

 

    Set<String> AccountTitle= new Set<String>();

    Set<String> setAccount = new Set<String>();

    List<Account> listAccount = new List<Account>();

    Map<String, IMP__c> mapImp = new Map<String, IMP__c>();

    List<IMP__c> listImp = new List<IMP__c>();

    List<IMP__c> listUpdtImp = new List<IMP__c>();

   

    if (Trigger.isInsert){

        for (Account Accounts : Trigger.new)

        {

          

              IMP__c imp = new  IMP__c(Name = Accounts.title,BR_ID__c=Accounts.Account__c,Description__c=Accounts.Body,Region_User__c=Accounts.Region__c);

              listImp.add(imp);

          

        }

        insert listImp;

    }

    if (Trigger.isUpdate){

        for (Account Accounts : Trigger.new)

        {

            

              listAccount .add(Accounts );

              setAccount.add(Accounts.Account__c);

                             

             }

 

   

   

            listImp  = [select Name,BR_ID__c,Description__c,Region_User__c from IMP__c where  BR_ID__c in :setAccount];

        for( IMP__c imptmp : listImp ){

            mapImp.put(imptmp.BR_ID__c,imptmp);

        }

        for( Account Accounttmp : listAccount  ){

            if( mapImp.get(Accounttmp.Account__c) != null ){

                 IMP__c uptIMP = mapImp.get(Accounttmp.Account__c);

                  

                

                 uptIMP.Description__c=Accounttmp.Body;

                 uptIMP.Name  = Accounttmp.title;  

                 uptIMP.Region_User__c   =Accounttmp.Region__c;

                 listUpdtImp.add(uptIMP);

            }else{

                 IMP__c imp = new  IMP__c(Name = Accounttmp.title,BR_ID__c=Accounttmp.Account__c,Description__c=Accounttmp.Body,Region_User__c=Accounttmp.Region__c);

                 listUpdtImp.add(imp);

            }

        }

        upsert listUpdtImp;

    

    }

    }

 

 

Please Help!

 

Richa

Hello,

Can anyone help to write a logic to merge duplicate records of Custom Object?

 

Thanks,

Shruti

I have a picklist that I am trying to generate from a class.  The idea is that when a user picks an item from the list that they will be redirected to the corresponding page.  When I use the code snippet below in a test page where the class is set as the "Controller=class" it works great.  However, when I add the class to another page as "extensions=class", the drop down list will not render any values.

 

Any ideas on how to get this to render properly.

 

Visualforce:

 

<apex:page standardController="Task" extensions="taskManagementRedirectPicklist" tabStyle="Task">
<apex:form >	
	<apex:pageBlock title="Selection Criteria">		
		
		<apex:pageBlockSection showHeader="false" title="Options" columns="3">
			<apex:pageBlockSectionItem >
				
				<apex:selectList value="{!picklistvalue}" size="1" >
			    	<Apex:selectOptions value="{!item}"/>
			    	<apex:actionSupport event="onchange" action="{!redirect}" />    
			    </apex:selectList>
			    		
			</apex:pageBlockSectionItem>
	    </apex:pageBlockSection>
	</apex:pageBlock>
</apex:form>
</apex:page>

 

Apex Class:

 

public with sharing class taskManagementRedirectPicklist {
	
	private ApexPages.StandardController controller;
	
	public taskManagementRedirectPicklist(ApexPages.StandardController stdController) {
      controller = stdController;
   }   
	
	public list<selectoption>item{get;set;}
	public string picklistvalue{get;set;}
	
	public taskManagementRedirectPicklist()
	{
	    item=new list<selectoption>();
	    item.add(new selectoption('myTasks','Tasks Assigned to Me'));
	    item.add(new selectoption('myDelegatedTasks','Tasks I Assigned to Others'));
	}
 
	public pagereference redirect()
	{
	     PageReference pageRef= new PageReference('/apex/'+picklistvalue);
	    pageRef.setredirect(true);
	    return pageRef;
	}

}

 

  • August 19, 2013
  • Like
  • 0

Hi,

 

I want to write the trigger which send the email notifications when the case is closed.

 

Can any one help for this?

 

 

Regards.,

R.Ambiga

Hi All,

      Requirement is to upload a CSV file which carries multilingual character and Special characters into Salesforce using custom functionality [using VF and apex], but when I try to upload that file and converting blob to String getting error as 'Blob is Invalid UTF -8 String' .How to solve this issues.

Hi Friends ,

Can anyone help me in resolving this code .

Error: Compile Error: Method does not exist or incorrect signature: [String].day() at line 19 column 37

 

// memberBirthdayBatch:

global class memberBirthdayBatch implements Database.batchable<Member__c>
{
global Iterable<Member__c> start(Database.batchableContext info)
{
System.debug('Start method');
return new callMemberIterable();
}
global void execute(Database.batchableContext info, List<Member__c> scope)
{
List<Member__c> memsToUpdate = new List<Member__c>();
System.debug('Member list size is ' + scope.size());
for(Member__c m : scope)
{
Date myDate = date.today();
Integer todayDy = myDate.day();
Integer todayMon = myDate.month();
System.debug('Day is ' + m.BirthDay__c.day());
Integer dy = m.BirthDay__c.day();
Integer mon = m.BirthDay__c.month();
if(todayDy == dy && todayMon == mon)
{
Messaging.SingleEmailMessage email = new Messaging.SingleEmailMessage();
List<String> toAddresses = new List<String>();
toAddresses.add(m.EmailAddress__c);
email.setToAddresses(toAddresses);
List<String> ccAddresses = new List<String>();
ccAddresses.add('salesforcecrm@gmail.com');
email.setCcAddresses(ccAddresses);
email.setSubject('Happy Birthday. Have a blast -- Birthday Reminder!');
String message = '<html><table cellspacing = "7"><tr><td style="font-weight:bold;color:green;">Happy Birthday!!!</td></tr><tr><td style="font-weight:bold;color:pink;">Many more Happy returns of the day.</td></tr><tr><td></td></tr><tr><td></td></tr><tr><td style="font-weight:bold;">Cheers,</td></tr><tr><td style="font-weight:bold;">XYZ</td></tr></table></html>';
email.setHtmlBody(message);
Messaging.sendEmail(new Messaging.SingleEmailMessage[]{email});
}
}
}
global void finish(Database.batchableContext info)
{
}
}

 

Thanks in advance

 

  • August 17, 2013
  • Like
  • 0

I am attempting to write a SOQL query to find the following.   Having trouble with the "join" etc.

 

We have a Custom Object called Shipment, the parent object is Account. 

 

Related by:

Shipment.SF_Account__c = Account.Id

 

Shipment has a field called CustomerNo.  Account has a field Site.   I want a list of Shipment records where CustomerNo does NOT equal the related Account Site.

 

In SQL it would look like:

SELECT Shipment.ID, Shipment.CustomerNo, Account.Site FROM Shipment INNER JOIN Account ON Shipment.SF_Account__c = Account.ID WHERE Shipment.CustomerNo <> Account.Site