• krpr
  • NEWBIE
  • 78 Points
  • Member since 2012

  • Chatter
    Feed
  • 3
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 3
    Questions
  • 38
    Replies
Hi 
This is my code please help me 
VF Page
-------------
<apex:page controller="pagination1">
<apex:form >
<apex:pageBlock id="details">
<apex:pageblockTable value="{!accountlist}" var="account">

<apex:column value="{!account.name}"/>
<apex:column value="{!account.rating}"/>
<apex:column value="{!account.phone}"/>
<apex:column value="{!account.NumberOfEmployees}"/>
</apex:pageblockTable>
<apex:pageBlockButtons >
<apex:commandButton value="Fisrt" action="{!first}" reRender="details" disabled="{!prev}"/>
<apex:commandButton value="Previous" action="{!prev}" reRender="details" disabled="{!prev}"/>
<apex:commandButton value="Next" action="{!nxt}" reRender="details" disabled="{!nxt}"/>
<apex:commandButton value="Last" action="{lst}" reRender="details" disabled="{!nxt}"/>

</apex:pageBlockButtons>

</apex:pageBlock>


</apex:form>
 
</apex:page>

Apex 
-------------
public class pagination1 {

   public class Pagination
{
private integer totalRecs = 0;
private integer OffsetSize = 0;
private integer LimitSize= 10;
public Pagination()
{
totalRecs = [select count() from account];
}
public List<account> getacclist()
{
List<account> acc = Database.Query('SELECT Name, rating, phone, numberofemployees,FROM account LIMIT :LimitSize OFFSET :OffsetSize');
System.debug('Values are'+ acc);
return acc;
}
public void First()
{
OffsetSize = 0;
}
public void previous()
{
OffsetSize = OffsetSize - LimitSize;
}
public void next()
{
OffsetSize = OffsetSize + LimitSize;
}public void Last()
{
OffsetSize = totalrecs – math.mod(totalRecs,LimitSize);
}
public boolean getprevious()
{
if(OffsetSize == 0)
return true;
else
return false;
}
public boolean getnext()
{
if((OffsetSize + LimitSize) > totalRecs)
return true;
else
return false;
}
}
I have an insert/update trigger (not written by me) on the case object which has been working fine.
I have now added a couple of new case record types but this trigger does not appear to run for either of them. Is there something I need to set to activate the trigger against these new record types?

I had assumed that the trigger was against the Case object and so would run irrespective of the record type. I am new to Apex code altogether and have a problem with knowing where to start with trying to debug this problem. There does not seem to be any hard code that refers to the record type for functions that would eliminate these record types.

Hi,

 

I am actually trying to build a very basic trigger on opportunities.

 

The field country_object__c is a lookup field to an object with country information.

The selection he makes there (country name) should be filled into the country__c field when the entry is saved.

 

The code below however only puts in the id of the country object record.

 

Background is that the field country__c is used in many reports and sharing rules which I do not want to rework.

 

Many thanks!!!!

 

 

Trigger Update_Country on Opportunity (before update, before insert) {

 // Fill the Country__c field with the lookup name
 
  for (Opportunity o : Trigger.new) {
     o.Country__c = o.Country_Object__c;
  }

}

 

Hi ,

 

Does anyone have Idea about this :

 

OutputLink does not open new Tab in Service Console. It opens new Tab outside Console.

 

<apex:outputLink value="/{!mDup.existing.ID}" target="_blank" style="color: blue;">{!mDup.existing.name}</apex:outputLink>

 

Thanks

  • July 27, 2012
  • Like
  • 0
I would like to able to merge Companies and Contacts on Salesforce regardless of whether or not the Companies and Contacts have been integrated to another system. 
When the records are merged I would like the other systems integrated to Salesforce to be notified. 
After the merge has completed the Id's of the record that has been updated will be sent from Salesforce to <External System> 
The Id's of the records that have been deleted as part of the merge process will also be sent to <External System>
I wanted to know if there is a way to trigger the outbound message when a contact is deleted. It seems that it does not trigger the outbound message when an existing contact is deleted or merged.
If yes could you please provide a working example.
Thnaks in advance
  • April 30, 2012
  • Like
  • 0

I am experiencing a strange behavior that none of the triggers are firing on contact when validation rules are active. The validation rule is blocking and I can't see trigger firing. Used to work before and nothing changed but after spring 12 release it stopped working.

 

If I deactivate Validation Rule the Trigger fires and does update .

 

 

  • March 14, 2012
  • Like
  • 0
Hi Guys,
I have date field in Vf Like : <apex:inputtext id="implatedDate" size="10" value="{!tissue.implanteddate}"/>
and  this "implanteddate" from Wrapper class. Also i have one command button "Next"
By clicking on Next button my page is refreshing and by that time date format is changing it to different format and showing the below error:
" Value 'Wed Dec 16 00:00:00 GMT 2015' cannot be converted from Text to com.force.swag.soap.DateOnlyWrapper "

​Please update me with your solution.
 
Hi All,
I have a requiremnt that an user cant select a date of past in date picker list in visual force page and if he selects/enters a date of past an error msg should be displayed.
Note:This date field on Vf page is a dummy field and is not present on object level.
I am attaching my Vf code and controller along with my screen shot.
public class HarjeetWrapper{
             private Set<Id> selectedContactIds;
             public String selectedActions{get;set;}
             public Date dat {get;set;}
              

            


            public ApexPages.StandardSetController setCon {
            get {
                if(setCon == null) {
                    setCon = new ApexPages.StandardSetController(Database.getQueryLocator(
                      [select Id, Name,csord__Status__c, csord__Account__c from csord__Subscription__c where csord__Account__c=:accountid ]));
                             }
                            setCon.setPageSize(20);
                        return setCon;
                }
        set;
    }
    public List<csord__Subscription__c > getWrapSubscriptionList() {
         
         // setCon.setpagesize(20);
         setCon.setpageNumber(1);
         return (List<csord__Subscription__c >) setCon.getRecords();
    }
    public Integer getPageNumber(){
 
        return this.setCon.getPageNumber();
 
    }
    

 


   Public Integer getTotalPages(){
 
        Decimal totalSize = this.setCon.getResultSize();
        Decimal pageSize = this.setCon.getPageSize();
 
        Decimal pages = totalSize/pageSize;
 
        return (Integer)pages.round(System.RoundingMode.CEILING);
     }
 

    //Our collection of the class/wrapper objects wrapAccount
    public List<wrapSubscription> wrapSubscriptionList {get; set;}
    public List<csord__Subscription__c> selectedSubscriptions{get;set;}
    public Boolean isCancel{get;set;}
    public string accountid;
    
    
    public HarjeetWrapper(){
      accountid=ApexPages.currentPage().getParameters().get('id');
        if(wrapSubscriptionList == null) {
           wrapSubscriptionList= new List<wrapSubscription>();
            for(csord__Subscription__c s: [select Id, Name,csord__Status__c, csord__Account__c from csord__Subscription__c where csord__Account__c=:accountid ]) {
                // As each Account is processed we create a new wrapAccount object and add it to the wrapAccountList
                wrapSubscriptionList.add(new wrapSubscription(s));
            }
        }
    }
    
    
    public void processSelected() {
    selectedSubscriptions = new List<csord__Subscription__c>();
 
        for(wrapSubscription wrapSubscriptionObj : wrapSubscriptionList) {
            if(wrapSubscriptionObj.selected == true) {
                selectedSubscriptions.add(wrapSubscriptionObj.sub);
            }
        }
    }
    
    public PageReference cancel(){
        return new PageReference('/'+accountid);
    }
    
    public void next(){

    if(this.setCon.getHasNext())
        this.setCon.next();

}

 public void previous(){

    if(this.setCon.getHasPrevious())
        this.setCon.previous();

}
        public List<SelectOption> getCountriesOptions() {
        List<SelectOption> countryOptions = new List<SelectOption>();
        countryOptions.add(new SelectOption('','-None-'));
        countryOptions.add(new SelectOption('Take Over','Take Over'));
        countryOptions.add(new SelectOption('Invoice Switch','Invoice Switch'));
        countryOptions.add(new SelectOption('Move','Move'));
        /*countryOptions.add(new SelectOption('Germany','Germany'));
        countryOptions.add(new SelectOption('Ireland','Ireland'));*/
 
        return countryOptions;
}




                         
 
    // This is our wrapper/container class. In this example a wrapper class contains both the standard salesforce object Account and a Boolean value
    public class wrapSubscription {
        public csord__Subscription__c sub {get; set;}
        public Boolean selected {get; set;}
 
        public wrapSubscription(csord__Subscription__c s) {
            sub = s;
            selected = false;
        }
    }
}
<apex:page docType="html-5.0" controller="HarjeetWrapper" sidebar="false" showHeader="false">



    <script type="text/javascript">
        function selectAllCheckboxes(obj,receivedInputID){
            var inputCheckBox = document.getElementsByTagName("input");
            for(var i=0; i<inputCheckBox.length; i++){
                if(inputCheckBox[i].id.indexOf(receivedInputID)!=-1){
                    inputCheckBox[i].checked = obj.checked;
                }
            }
        }
    </script>
    <apex:form >
        <apex:pageBlock >
        <apex:pageBlockSection >
        <apex:pageBlockSectionItem >
        <!-- <apex:outputText value="{!selectedActions}" label="You have selected:"/>-->
        <!--<apex:outputText label="Select the Action:"/>-->
        Select the Action:
        <!--<apex:outputPanel>-->
          <apex:selectList value="{!selectedActions}" multiselect="false" size="1">
                <apex:selectOption itemValue="Take Over" itemLabel="Take Over"/>
                <apex:selectOption itemValue="Invoice Switch" itemLabel="Invoice Switch"/>
                <apex:selectOption itemValue="Move" itemLabel="Move"/>
            </apex:selectList>
            <!--</apex:outputPanel>-->
            </apex:pageBlockSectionItem>
           </apex:pageBlockSection> 
           <apex:PageBlockSection >
            <apex:pageBlockSectionItem >
                Date: <apex:input type="date" value="{!dat}" required="true" />
             </apex:pageBlockSectionItem>
            <!--<apex:input value="{!myDate}" id="theTextInput" type="date"/>-->
        </apex:pageBlockSection>
    </apex:pageBlock>
 
    
        <apex:pageBlock title="Select Subscription"  >
            <apex:pageBlockButtons location="bottom">
                <apex:commandButton value="Proceed " action="{!processSelected}" />
                <apex:commandButton value="Cancel" action="{!cancel}" immediate="true" />
            </apex:pageBlockButtons>
       <apex:pageblockSection title="Subscriptions" collapsible="false" columns="1" >
             <apex:pageBlockTable value="{!wrapSubscriptionList}" var="subWrap">
                    <apex:column >
                        <apex:facet name="header">
                            <apex:inputCheckbox onclick="selectAllCheckboxes(this,'inputId')" />
                        </apex:facet>
                        <!--<apex:inputCheckbox value="{!subWrap.selected}" id="inputId"/>-->
                                <apex:inputCheckbox value="{!subWrap.selected}" id="inputId" disabled="{!NOT(subWrap.sub.csord__Status__c=='Active')}" />
                    </apex:column>
                    
                    <!--<apex:column value="{!subWrap.sub.Name}" />-->
                    <apex:column headerValue="Subscription Name" > 
                        <!--<apex:commandLink value="{!subWrap.sub.Name}" action="/{!subWrap.sub.Id}"/>-->
                       <apex:outputLink value="/{!subWrap.sub.Id}" target="_blank"> {!subWrap.sub.Name} </apex:outputLink>
                   </apex:column>
                     <apex:column value="{!subWrap.sub.csord__Status__c}" />
                    <apex:column value="{!subWrap.sub.csord__Account__c}" />
                </apex:pageBlockTable>
                </apex:pageblockSection>
             <apex:commandButton rendered="{!setCon.hasPrevious}" value="first" action="{!setCon.first}"/>
            <apex:commandButton rendered="{!setCon.hasPrevious}" value="Previous" action="{!setCon.previous}"/>
            <apex:outputLabel value=" (page {!pageNumber} of {!totalPages})"/>
            <apex:outputText rendered="{!(setCon.pageNumber * setCon.pageSize) < setCon.ResultSize}" value="{!setCon.pageNumber * setCon.pageSize} Of {!setCon.ResultSize}"></apex:outputText>
            <apex:outputText rendered="{!(setCon.pageNumber * setCon.pageSize) >= setCon.ResultSize}" value="{!setCon.ResultSize} Of {!setCon.ResultSize}"></apex:outputText>
            <apex:commandButton rendered="{!setCon.hasNext}" value="next" action="{!setCon.next}"/>
            <apex:commandButton rendered="{!setCon.hasNext}" value="last" action="{!setCon.last}"/>

     <apex:pageBlock />
                
                
                <apex:pageblockSection title="Selected Subscriptions" collapsible="false" columns="1" >
                   <apex:pageBlockTable value="{!selectedSubscriptions}" var="c" id="table2" title="Selected Subscriptions" width="100%">
                    <!--<apex:column value="{!c.Name}" headerValue="Subscription Name"/>-->
                    <apex:column headerValue="Subscription Name" > 
                        <apex:commandLink value="{!c.Name}" action="/{!c.Id}" target="_blank"/> 
                      </apex:column> 
                    <apex:column value="{!c.csord__Status__c}" headerValue="Status"/>
                    <apex:column value="{!c.csord__Account__c}" headerValue="Account"/>
                </apex:pageBlockTable>
            

            </apex:pageblockSection>
        </apex:pageBlock>
    </apex:form>
 
</apex:page>
my screen shot
Please help me out in this situation,i really need to solve this as soon as possible.

Mnay thanks in advance.
 




 
Hi all ,

         Can anybody explain what is the difference between opportunity line item and product and what is the juction object here..?
Hi 
This is my code please help me 
VF Page
-------------
<apex:page controller="pagination1">
<apex:form >
<apex:pageBlock id="details">
<apex:pageblockTable value="{!accountlist}" var="account">

<apex:column value="{!account.name}"/>
<apex:column value="{!account.rating}"/>
<apex:column value="{!account.phone}"/>
<apex:column value="{!account.NumberOfEmployees}"/>
</apex:pageblockTable>
<apex:pageBlockButtons >
<apex:commandButton value="Fisrt" action="{!first}" reRender="details" disabled="{!prev}"/>
<apex:commandButton value="Previous" action="{!prev}" reRender="details" disabled="{!prev}"/>
<apex:commandButton value="Next" action="{!nxt}" reRender="details" disabled="{!nxt}"/>
<apex:commandButton value="Last" action="{lst}" reRender="details" disabled="{!nxt}"/>

</apex:pageBlockButtons>

</apex:pageBlock>


</apex:form>
 
</apex:page>

Apex 
-------------
public class pagination1 {

   public class Pagination
{
private integer totalRecs = 0;
private integer OffsetSize = 0;
private integer LimitSize= 10;
public Pagination()
{
totalRecs = [select count() from account];
}
public List<account> getacclist()
{
List<account> acc = Database.Query('SELECT Name, rating, phone, numberofemployees,FROM account LIMIT :LimitSize OFFSET :OffsetSize');
System.debug('Values are'+ acc);
return acc;
}
public void First()
{
OffsetSize = 0;
}
public void previous()
{
OffsetSize = OffsetSize - LimitSize;
}
public void next()
{
OffsetSize = OffsetSize + LimitSize;
}public void Last()
{
OffsetSize = totalrecs – math.mod(totalRecs,LimitSize);
}
public boolean getprevious()
{
if(OffsetSize == 0)
return true;
else
return false;
}
public boolean getnext()
{
if((OffsetSize + LimitSize) > totalRecs)
return true;
else
return false;
}
}

write a trigger on invoice line item(child object) to update account balence as sum fo all associated invoices amount for the account.
child obj:invoice
fields:invioce number,invoice date, invoice amount(rollup), account name(lookup with account)
obj2: invoice line iteam
fields:invoice(MD with invoice),product,quantity,unit price,total price(Formula,Qua*UNT pri)
account coustem field: account balance(currency data type)
Hi friends,

I have a requirement to check for holidays. I am quering the ActivityDate from Holiday in my controller which gives me a list. But the ActivityDate is not getting the proper holiday date. The date which is coming in the ActivityDate is nowhere related to the correct holiday.I didnt find any other field in holiday to fetch the required dates.
I am not sure whether the issue is because of recent release.
Can anyone help in fixing the issue?

Thanks in advance
Spacing between columns is not uniform.How to fix spacing

<apex:page standardController="Account">
   <apex:form >
      <apex:pageBlock title="My Block">
           <apex:pageBlockSection title="My Section" columns="4" collapsible="false">
                <apex:outputField value="{!Account.Field1__c}"/>
                <apex:outputField value="{!Account.Field2__c}"/>
                <apex:outputField value="{!Account.Field3__c}"/>
                <apex:outputField value="{!Account.Field4__c}"/>
                <apex:outputField value="{!Account.Field5__c}"/>
                <apex:outputField value="{!Account.Field6__c}"/>
                <apex:outputField value="{!Account.Field7__c}"/>
                <apex:outputField value="{!Account.Field8__c}"/>
              </apex:pageBlockSection>
         </apex:pageBlock>
  </apex:form>
Always the value of acceptTerms is showing as false even the check box is checked in the page.

Please help me out to solve this.

vf Page:

<apex:inputCheckbox value="{!acceptTerms}"/>

controller:

public  class controller {

Public boolean accepTerms;

Public controller(){
accepTerms=false;

}

if(!acceptTerms)
apex.addmessage('   ' );

}

Hi,
     i have two users  one user is using currency as Rupee and another user is using Dollar,if i'm generating pdf for these currency fileds how to get the currency symbols for ( U S user $, indian User Rupee) automatically .



Thanks,
Sanjeev

Hi,

How do I ensure an AJAX update request finishes before users click elsewhere on the VF page?

Here's my VF code...

                        <apex:inputField value="{!s.Quantity}" style="width:70px" required="false">
                            <apex:actionsupport event="onchange" action="{!ApprovalRequired}" rerender="selected" status="actionStatusQuantity">
                                <apex:param value="{!s.PriceBookEntryId}" assignTo="{!toCurrent}" name="toCurrent"/>
                            </apex:actionsupport>
                            <apex:actionStatus id="actionStatusQuantity" startText="Calculating..." stopText=""/>                           
                        </apex:inputField>

This displays a processing message but does not stop users clicking elsewhere e.g. on a Save commandbutton, before it has completed.  I need it to complete and the rerender="selected" command to always run.

Regards
Lance Cresswell

hi
am not able to cover the test class for this trigger can any one help me how to cover the record types in the test class
below is the my trigger and test class


trigger DuplicateCR on Requirement__c (before insert,before update)
{
    String dupErrMsg = 'good';
    String stgSkipMsg = 'yyy';
    String enquiryStatusInvalid = 'xxxx';
 
    List<Requirement__c> cRObjectList = new List<Requirement__c>();
    cRObjectList = [SELECT First_Name__c,Last_Name__c,Phone_Number__c,Email_Id__c
     FROM Requirement__c limit 50000];
     
    
     
    for(Requirement__c tempCR :trigger.new)
    {
        for(Requirement__c tempCurCR : cRObjectList)
        {
            id RT_Client=Schema.SObjectType.Requirement__c.getRecordTypeInfosByName().get('Requirement').getRecordTypeId();
       
            if(System.Trigger.IsInsert && tempCR.RecordTypeId==RT_Client
            && (tempCR.First_Name__c==tempCurCR.First_Name__c &&
             tempCR.Last_Name__c == tempCurCR.Last_Name__c)
            && tempCR.Phone_Number__c == tempCurCR.Phone_Number__c &&
            tempCR.Email_Id__c == tempCR.Email_Id__c
            && tempCR.Duplicate__c==false)
            {
                 tempCR.addError(dupErrMsg);           
            }
                    
        }
        
        id RT_customer=Schema.SObjectType.Requirement__c.getRecordTypeInfosByName().get('Cus Requirement').getRecordTypeId();
            
        if(tempCR.RecordTypeId==RT_customer && tempCR.Detail__c != NULL)
        {
            Customer__c newCustObj=[SELECT First_name__c,Last_name__c FROM Customer__c WHERE
                                     Id = :tempCR.Detail__c];
            tempCR.First_Name__c=newCustObj.First_name__c;
        }
        
        
    }
}


test class

@IsTest(SeeAllData=true)
public class Test_DuplicateCR
{
public static testmethod void T_DuplicateCR()
{
Requirement__c cr=new Requirement__c();
cr.Salutation__c='Mr';
cr.First_Name__c='test';
cr.Last_Name__c='test1';
cr.Phone_Number__c='9999999999';
cr.Email_Id__c='test@gmail.com';
cr.Min_Area_Sq_Ft__c='500';
cr.Max_Area_Sq_ft__c='600
insert cr;
cr.Min_Area_Sq_Ft__c='600';
cr.Max_Area_Sq_ft__c='700';
update cr;
}
}

 

 

 

 

Regards

venkatesh

trigger Order on Project_Item__c (after insert, after update, after delete) {
Set<Id> setId = new Set<Id>();
for(Project_Item__c pi:trigger.new)
      setId.add(pi.Master_Detail__c);
Map<Id,Project__c> mapProject = new Map<Id, Project__c>([SELECT Id, Total_Open_custom__c,  Total_Pipeline_custom__c FROM Project__c WHERE Id in:setId]); 

for(Project_Item__c item:trigger.new){
      if(item.status__c=='Open'){
           if(mapProject.get(item.Master_Detail__c).Total_Open_custom__c==null){
                 mapProject.get(item.Master_Detail__c).Total_Open_custom__c=item.Total_Amount__c;
           }else{
                 mapProject.get(item.Master_Detail__c).Total_Open_custom__c+=item.Total_Amount__c;
             }
       }else if(item.status__c=='Pipeline'){
                 if(mapProject.get(item.Master_Detail__c).Total_Pipeline_custom__c==null){
                       mapProject.get(item.Master_Detail__c).Total_Pipeline_custom__c=item.Total_Amount__c;
                 }else{
                       mapProject.get(item.Master_Detail__c).Total_Pipeline_custom__c+=item.Total_Amount__c;
                 }
       }
}
if(trigger.isDelete){
      for(Project_Item__c pi1 : trigger.new){
if(pi1.status__c=='Open'){
if(mapProject.get(pi1.Master_Detail__c).Total_Open_custom__c==null){
mapProject.get(pi1.Master_Detail__c).Total_Open_custom__c=pi1.Total_Amount__c;
}else{
mapProject.get(pi1.Master_Detail__c).Total_Open_custom__c-=pi1.Total_Amount__c;
}
}else if(pi1.status__c=='Pipeline'){
if(mapProject.get(pi1.Master_Detail__c).Total_Pipeline_custom__c==null){
mapProject.get(pi1.Master_Detail__c).Total_Pipeline_custom__c=pi1.Total_Amount__c;
}else{
mapProject.get(pi1.Master_Detail__c).Total_Pipeline_custom__c+=pi1.Total_Amount__c;
}
}
}
}
update mapProject.values();
}

 

When i deleted item of Project_Item__c, it showed a message : The first validation error encountered was "Apex trigger Order caused an unexpected exception, contact your administrator: Order: execution of AfterDelete caused by: System.NullPointerException: Attempt to de-reference a null object: Trigger.Order: line 3, column 1".

 

Please help me!

Hi All,

 

I am tryig to call an external service and then I am getting the following error.

 

System.CalloutException: Web service callout failed: Unable to find header type info for *specific soap header*

 

Does anyone have any idea what this means?

 

 

Regards

 

Rony

/

Trigger code

 

trigger AddOwnerColor on Account (before insert, before update) {

// create a set of all the unique ownerIds
Set<Id> ownerIds = new Set<Id>();
for (Account a : Trigger.new)
  ownerIds.add(a.OwnerId);

// query for all the User records for the unique userIds in the records
// create a map for a lookup / hash table for the user info
Map<Id, User> owners = new Map<Id, User>([Select UserFavColor__c from User Where Id in :ownerIds]);

// iterate over the list of records being processed in the trigger and
// set the color before being inserted or updated
for (Account a : Trigger.new)
  a.Owner_Favorite_Color__c = owners.get(a.OwnerId).UserFavColor__c;

}

 

 

########################Test Classes##############################

@isTest
private class TestAccountColorTrigger {

static testMethod void testBulkInsert() {

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

  Profile p = [select id from profile where name='Marketing User'];
  // create a user to run the test as
  User u = new User(alias = 'test123', email='test1234@noemail.com',
         emailencodingkey='UTF-8', lastname='Testing1', languagelocalekey='en_US',
      localesidkey='en_US', profileid = p.Id, country='United States',
      UserFavColor__c='Buttercup Yellow',
      timezonesidkey='America/Los_Angeles', username='test1234@noemail.com');
  insert u;

  Profile p1 = [select id from profile where name='Standard User'];
  // create a user to own the account
  User u1 = new User(alias = 'test123', email='test12345@noemail.com',
      emailencodingkey='UTF-8', lastname='Testing', languagelocalekey='en_US',
      localesidkey='en_US', profileid = p1.Id, country='United States',
      UserFavColor__c='Pretty Pink',
      timezonesidkey='America/Los_Angeles', username='test12354@noemail.com');
  insert u1;

  // add 200 accounts to the list to be inserted
  for (Integer i=0;i<200;i++) {

      Account a = new Account(
          Name = 'Test Account',
          OwnerId = u1.Id
      );
      accounts.add(a);

  }

  // Switch to the runtime context
  Test.startTest();

  // run as a different user to test security and rights
  System.runAs(u) {
      insert accounts;
 }

  // Switch back to the original context
  Test.stopTest();

  // query for all accounts created and assert that the color was added correctly
  for (Account acct : [Select Owner_Favorite_Color__c from Account Where OwnerId = :u1.Id])
      System.assertEquals(acct.Owner_Favorite_Color__c,'Pretty Pink');

}
}

When creating a recurring task using Apex, how I can set the reminder to get the same functionality as what UI offers?

 

The Task object has only a "ReminderDateTime"! 

 

Task t = new Task();

t.Subject = 'Test';

t.IsReminderSet = true;

t.RecurrenceType = 'RecursEveryWeekday';

t.RecurrenceDayOfWeekMask = 62;

t.ReminderDateTime = ??   //this is a date time field, How to set to : "On occurrence date" at "8:00 am" for each occurrence? 

 

insert t;

 

 

I have created a VF page that renders as PDF file. Now I want to save that PDF file onclick of same button to static resource. Is that possible? Means I have a button on click of which I got a VF page as PDF file. Instead of popping up this page as PDF file I want this PDF to save in my static resource.

 

Thanks,