• Gil Gourévitch
  • NEWBIE
  • 270 Points
  • Member since 2014
  • NEOXIA


  • Chatter
    Feed
  • 10
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 0
    Questions
  • 46
    Replies
Hi All,

   I want to get test coverage code for date and time methods.
   Methods looks like

   public String dateCalulate(Date dtDate)
   {
    ////////////////////
   }

   public String timeCalulate(String strTime)
   {
         String strTime1='00:00:00';
            if(strTime == '12:00 AM')   strTime1='00:00:00';
            else if(strTime == '11:30 PM')  strTime1='23:30:00';
            else if(strTime == '11:45 PM')  strTime1='23:45:00';
             
             return strTime1;
   }
Hi,
Could you help me with the problem below. I got the error "No access to entity: Calendar in row 1, column 8", but I didn't know exactly the error.
Is the following syntax ok?
 
IF(Calendar.Year(EZR.Beginn_der_HV__c) = This.Year) { 
  Bestandsentwicklung_CY++; 
}
The field Beginn_der_HV__c includes dates. I want to count the Beginn_der_HV__c if the calendar year from this field is like current year, also I need to count the field if the calendar year from this field is like current year - 2.

Thanks for your help, Sascha
 
public class testfor6_c {

private Id accId {get; set;}
public testfor6_c(ApexPages.StandardController stdcontroller) { 
    accId = stdcontroller.getRecord().Id;

    Bestandsentwicklung_CY = 0;
    Bestandsentwicklung_CY_2 = 0;

    getEZRen();   
}

public Integer Bestandsentwicklung_CY {get; set;}
public Integer Bestandsentwicklung_CY_2 {get; set;}

public void getEZRen() {

List<Einzelrisiko__c> EZRList = [SELECT Beginn_der_HV__c FROM Einzelrisiko__c WHERE Abgangsdatum__c = Null AND Unternehmens_Id_Long__c = :accId]; 

FOR (Einzelrisiko__c EZR : EZRList) { 

    IF(Calendar.Year(EZR.Beginn_der_HV__c) = This.Year) { Bestandsentwicklung_CY++; }
    IF(Calendar.Year(EZR.Beginn_der_HV__c) = This.Year-2) { Bestandsentwicklung_CY_2++; }    

} } }



 
Hi all,
I'm new for salesforce help me please. Why I can't open visualforce page by button.
This is my code

public PageReference onSave(){
        upsert(lstProductService);
        String url = 'Cost_Calculator_2?&CF00NO0000001EtuG_lkid='+theProduct.Id+'&CF00NO0000001EtuG='+theProduct.Name;
        PageReference pref=new PageReference('/'+url);
        return pref;
    }

This is my page.
User-added image

This code in visualforce page.
             <center><apex:commandButton value="Save" action="{!onSave}"/></center>

I want open the another page by visualforce page.
Thank you for ans.
Hi,

I have written a Trigger where in i am Preventing duplicate Contact on a Child Account when Same contact appears on the Parent account.

trigger Duplicate on Contact (before insert , before update) {

        set<Id> accIds = new set<Id>();
    set<Id> parentIds = new set<Id>();
    
     for(Contact p :trigger.new){
        accIds.add(p.accountId);
}
map<Id,account> parentAccmap = new map<Id,account>([select Id,parentId,recordtypeId from account where Id IN :accIds and parentId!=NULL and recordtypeId='012600000005J5J']); //add Site record type Id here.
    for(account a:parentAccmap.values()){
        parentIds.add(a.parentId);
        }
        map<Id,Contact> parentPrMap = new map<Id,Contact>();
    list<Contact> prParentlist = [select ID,Email,AccountId, Account.recordtypeId from Contact where AccountId IN:parentIds and Account.recordtypeId='012600000005J5I']; //add Customer record type Id here.
    for(Contact pr:prParentlist){
        parentPrMap.put(pr.AccountId, pr);
        }
        for(Contact prr:trigger.new){
        if(prr.email!=null && parentAccmap.containsKey(prr.Accountid) && parentPrMap.containsKey(parentAccmap.get(prr.Accountid).ParentId)){
            if(prr.email == parentPrMap.get(parentAccmap.get(prr.Accountid).ParentId).email){
            String baseUrl = URL.getSalesforceBaseUrl().toExternalForm()+'/02Z/e?parentId=';
string errorMsg = '<a style=\'color:1B2BE8\'href="'+baseUrl+ prr.accountid +'"> Please Create a Contact Role  </a>';
                prr.addError('This Contact already exists.'+ errorMsg,false);
            }
        }
    }
}

Can some one help me with logic or modification to the above trigger so that if that contact is present on any of the Child Accounts of the Parent account, error should be thrown.
  • October 21, 2014
  • Like
  • 0
Hi,

I have a requirement where I need to access the controller's List into javascript.
Below is my partial code which I have tried with.

<apex:component controller="MyCompController">
    ---
    ---
        <script>
        Var arr1 = new Array();      // OR var arr1 = [];        
             <apex:repeat value="{!AccountIdList}" var="accId">
            arr1.push('{!accId}');
             </apex:repeat >                    
         alert('#### elements :' +arr1);        
         </script>
    ---
    ---

</apex:component>


controller
=====================
public class MyComponentController
{
    public List<String> AccountIdList {get; set;}   
    public MyComponentController()
    {
        List<Account> acc = [Select name, id from account];
        for(Account a : acc)
        {
            AccountIdList.add(a.id);
        }    
    }
    
}

Is anything wrong I have done? Please help.
 
Hi all,
I am new to visualforce. After query of records, I would like to update the same records with to the database but i am unable to save becuse there is no attribute receive data from the visualforce page.
This code vf page

<apex:page standardController="Product_Service__c" extensions="CostCalculationExtention">

    <script language="javascript">  
        function IsNumeric(sText,obj){  
            var ValidChars = "0123456789.";  
            var IsNumber=true;  
            var Char;  
            for (i = 0; i < sText.length && IsNumber == true; i++){   
                Char = sText.charAt(i);   
                if (ValidChars.indexOf(Char) == -1){  
                    IsNumber = false;
                }
            }
            if(IsNumber==false){  
                alert("Input number only!!");  
                obj.value=sText.substr(0,sText.length-1);  
            }  
       }  
    </script>
    
<apex:sectionHeader Title="Cost Calculation" subtitle="{!theProduct.Name}"/>
<apex:form >
    <apex:pageBlock title="Cost Calculation">
        <apex:pageblockTable value="{!lstProductService}" var="lstPS">
            
            <apex:column headerValue="Service">
                <apex:outputField value="{!lstPS.Service__r.Name}"/>
            </apex:column>
            
            <apex:column headerValue="Client Exp - Adult">
                 <apex:inputField id="clientAdult" value="{!lstPS.Client_Expense_Adult__c}" onkeypress="IsNumeric(this.value,this)"/>
            </apex:column>
            
            <apex:column headerValue="Client Exp - Child">
                <apex:inputField id="clientChild" value="{!lstPS.Client_Expense_Child__c}" onkeypress="IsNumeric(this.value,this)"/>
            </apex:column>
            
            <apex:column headerValue="T/L Exp">
                <apex:inputField id="tlExp" value="{!lstPS.Tour_Leader_Expense__c}" onkeypress="IsNumeric(this.value,this)"/>
            </apex:column>
            
            <apex:column headerValue="L/G Exp">
                <apex:inputField id="lgExp" value="{!lstPS.Local_Guide_Expense__c}" onkeypress="IsNumeric(this.value,this)"/>
            </apex:column>
            
            <apex:column headerValue="Coach">
                <apex:inputField id="coach" value="{!lstPS.Coach__c}" onkeypress="IsNumeric(this.value,this)"/>
            </apex:column>
        
        </apex:pageblockTable>
        <br/>
        <center><apex:commandButton value="Save"/></center>
    </apex:pageBlock>
    
</apex:form>
</apex:page>

This picture result code.
User-added image

This code controller.
public with sharing class CostCalculationExtention{
    
    //-- Open Page --\\
    public Product__c theProduct {get; set;}
    private String productId {get; set;}
    public Product_Service__c[] lstProductService {get; set;}
    //-- Open Page --\\
    
    //-- Constructor --\\
    public CostCalculationExtention(ApexPages.StandardController controller) {
        
        productId = apexpages.currentpage().getparameters().get('CF00NO0000001EtuG_lkid');
        //system.debug('ProductId : ' + productId);
        theProduct = [select id, name from Product__c where id =: productId];
        //system.debug('The Product : ' + theProduct);
        lstProductService = [select id, name, Service__r.Name, Client_Expense_Adult__c, Client_Expense_Child__c, Tour_Leader_Expense__c, Local_Guide_Expense__c, Coach__c from Product_Service__c where Product__r.id =: theProduct.Id];
        //system.debug('List Product_Service : ' + lstProductService);
        
    }
    //-- Constructor --\\
    
    //-- Save --\\
    public PageReference onSave(){
        
        return new PageReference('/' + ApexPages.currentPage().getParameters().get('CF00NO0000001EtuG_lkid'));
    }
    //-- Save --\\
}


I want to know what they should do next .

Thank you!!.
Hi Everyone...

I just want to get the following highlighted table on to vf  just by using standard controller....


User-added image
hi all ,

i have xyz related list on an account record.
i'll be creating a "new button" for that related list.

Problem:
However,through standard new button,it displays the record type select record type page.
How do i achieve this through my custom button?

Thanks
trigger Trigger_Task_Send_Email on Task (after insert)
{
  
    Set<Id> ownerIds = new Set<Id>();
 
    for(Task ta: Trigger.New)
    ownerIds.add(ta.ownerId);
 
    // --------------------Build a map of all users who are assigned the tasks.-----------------------------------
  
Map<Id, User> userMap = new Map<Id,User>([select Name, Email from User where Id in :ownerIds ]);
    for(Task ta : Trigger.New)
    {
        User theUser = userMap.get(ta.ownerId);
//-------------------------Mail Messenging-------------------------------------------------------

        Messaging.SingleEmailMessage mail = new Messaging.SingleEmailMessage();
        String[] toAddresses = new String[] {theUser.Email};

        if(ta.Email_Bcc__c!=null)
        {
        string[] BccAddresses =String.valueOf(ta.Email_Bcc__c).Split(',');
         mail.setBccAddresses(BccAddresses);
         }
       
         if(ta.Email_To__c!=null)
        {
         string[] toaddress =String.valueOf(ta.Email_To__c).Split(',');
         mail.setToAddresses(toaddress);
         }
         if(ta.Email_CC__c!=null)
         {
         string[] ccAddresses =String.valueOf(ta.Email_CC__c).Split(',');
         mail.setCcAddresses(ccAddresses);
       
       
         mail.setSubject('New Task Created by  '+ Userinfo.getName()  +'');
         }  
        //---------------------------------------- Creating Template----------------------------------
String template =  'New Task \n\nTo: '+theUser.Name+',\n\n '+ Userinfo.getName()  +' has assigned you the following task: \n\n';
      
        template+= 'Subject - {1}\n';
        template+= 'Due Date - {2}\n';
        template+= 'Priority - {3}\n';
        String duedate = '';
        if (ta.ActivityDate==null)
            duedate = '';
        else
            duedate = ta.ActivityDate.format();

     if(ta.Description!=null)
        {
            template+='Description - '+ta.Description+'\n';
          
        }

        List<String> args = new List<String>();
        args.add(theUser.Name);
        args.add(ta.Subject);
        args.add(duedate);
        args.add(ta.Priority);
// -----------------------For Creating Task Link--------------------------
        template+= '\n\nFor more details, click the following link: \n\n';
        template+= URL.getSalesforceBaseUrl().toExternalForm() + '/' + ta.Id; 
          
        mail.setSaveAsActivity(false);
        mail.setPlainTextBody(template);
     
        // Here's the String.format() call.
        String formattedHtml = String.format(template, args);
     
        mail.setPlainTextBody(formattedHtml);
        Messaging.SendEmail(new Messaging.SingleEmailMessage[] {mail});
    }
}



Test class
---------------
@isTest
public class Test_Trigger_Task_Send_Email{
static testmethod void createTask(){
    task t = new task();
    t.priority = 'low';
    t.status = 'In Progress';
    //t.ActivityDate='Due date';
    t.description = 'testing description';
    t.Email_To__c = 'a@b.com';
    t.Email_Bcc__c = 'a@b.com';
    t.Email_CC__c = 'a@b.com';
   
    test.startTest();
   
    insert t;
   
    test.stopTest();
}
}


when i am deploy to server its throwing error like Invalid field Email_Bcc__c for SObject Task


i tried but i can't able to find out the error.how to solve it
Hi guys, 

I have a problem I can't get my head around. 
I have a force.com site with pkb 2 and a few articles and I can't see my articles' content. 
On my site Public Access Settings I set read permissions.
For each article type I set the field level security to visible and read only.
pkb.Controller is in the Enabled Apex classes.
pkb_Home, pkb_RSS, and pkb_Template to the Enabled Visualforce Pages.
Data Category Group Visibility Settings related list is set to give visibility value to All Categories listed.

And I still can't see none of the Articles' content...
Your help is appreciated.
I have the following code and I am receiving this error: Invalid field Update_Contract_Request_Summary__c for SObject Opportunity. Does anyone know how to fix this? 
 
public class UpdateRequestContractExttwo_ecsg   {
    private final Opportunity opp;
     
    Opportunity tempOpp ;
   
    public UpdateRequestContractExttwo_ecsg(ApexPages.StandardController stdController) {
        this.opp = (Opportunity)stdController.getRecord();
        tempOpp = [select id ,ContactVerified__c,Contract_Specialist_Assigned__c, type,
                   Master_Agreement_Number__c,Current_Contract_Status__c,Date_Assigned_to_Specialist__c,
                   Date_Contract_Requested__c from Opportunity where id=: stdController.getId()];
        system.debug('--------------opp.id----------------'+opp.id );
    }
 
   
   //this is page load 
   public PageReference pageLoad(){
    
         PageReference oppPage = new ApexPages.StandardController(opp).view();
           oppPage.setRedirect(true);
            
      if(opp.Contract_Request_Date__c == null){ 
           ApexPages.Message errorMsg = new ApexPages.Message(ApexPages.Severity.Error,'A contract has not be requested for this Oppotunity yet');
           ApexPages.addMessage(errorMsg);
           return null ;
      
      }else if(Opp.Update_Contract_Request_Summary__c == null || Opp.Update_Contract_Request_Summary__c =='')
           {
                 ApexPages.Message errorMsg = new ApexPages.Message(ApexPages.Severity.Error,'Please enter Updated Contract Request Summary.');
                 ApexPages.addMessage(errorMsg);
                 return null ;
          }
         else
          {
              // set All associated ARs to Update from Oportunity
              List<Agreement_Request__c> AgreementRequests_to_update=new List<Agreement_Request__c>();
              AgreementRequests_to_update=[Select id,Request_Status__c,Opportunity__c from Agreement_Request__c where Opportunity__c=:opp.Id ];
              if(AgreementRequests_to_update.size()>0)
              {
                  for (Agreement_Request__c ar:AgreementRequests_to_update)
                  {
                      ar.Request_Status__c='Update from Opportunity';
                      ar.Updated_Agreement_Summary__c=opp.Updated_Agreement_Summary__c;
                  }
                 update AgreementRequests_to_update;
              }
                
              
           return oppPage;
         }
   }
   
}

 
Hi All,

   I want to get test coverage code for date and time methods.
   Methods looks like

   public String dateCalulate(Date dtDate)
   {
    ////////////////////
   }

   public String timeCalulate(String strTime)
   {
         String strTime1='00:00:00';
            if(strTime == '12:00 AM')   strTime1='00:00:00';
            else if(strTime == '11:30 PM')  strTime1='23:30:00';
            else if(strTime == '11:45 PM')  strTime1='23:45:00';
             
             return strTime1;
   }
trigger:
 
trigger easyopportunitytrigger on Easy_Opportunity__c (before insert, after insert, before update, after update, before delete, after delete, after undelete){
if(Trigger.isUpdate && Trigger.isAfter){
        easyopportunitytriggerhelper.oppbundle1(Trigger.new, trigger.oldmap);
        easyopportunitytriggerhelper.oppbundle2(Trigger.new, trigger.oldmap);
        easyopportunitytriggerhelper.oppbundle3(Trigger.new, trigger.oldmap);
        easyopportunitytriggerhelper.lostmaupsellaffiliates(Trigger.new, trigger.oldmap);
        easyopportunitytriggerhelper.lostmaupsellgassafetycheck(Trigger.new, trigger.oldmap);
        easyopportunitytriggerhelper.lostmaupsellhomebuy(Trigger.new, trigger.oldmap);
        easyopportunitytriggerhelper.lostmaupsellpattest(Trigger.new, trigger.oldmap);
        easyopportunitytriggerhelper.lostmaupsellremovals(Trigger.new, trigger.oldmap);
        easyopportunitytriggerhelper.lostmaupselluswitchelec(Trigger.new, trigger.oldmap);
        easyopportunitytriggerhelper.lostmaupselluswitchgas(Trigger.new, trigger.oldmap);
        easyopportunitytriggerhelper.lostmaupselluswitchwater(Trigger.new, trigger.oldmap);
        easyopportunitytriggerhelper.bundle1upsellConveyancing(Trigger.new, trigger.oldmap);
        easyopportunitytriggerhelper.bundle1upsellEPC(Trigger.new, trigger.oldmap);
        easyopportunitytriggerhelper.bundle1upsellHostedViewings(Trigger.new, trigger.oldmap);
        easyopportunitytriggerhelper.bundle1upsellMortgage(Trigger.new, trigger.oldmap);
        easyopportunitytriggerhelper.bundle1upsellSalesProgression(Trigger.new, trigger.oldmap);
        easyopportunitytriggerhelper.bundle2upsellBlockViewing(Trigger.new, trigger.oldmap);
        easyopportunitytriggerhelper.bundle2upsellMortgage(Trigger.new, trigger.oldmap);
        easyopportunitytriggerhelper.bundle2upselluswitchelec(Trigger.new, trigger.oldmap);
        easyopportunitytriggerhelper.bundle2upselluswitchgas(Trigger.new, trigger.oldmap);
        easyopportunitytriggerhelper.bundle2upselluswitchwater(Trigger.new, trigger.oldmap);
        easyopportunitytriggerhelper.bundle3upsellConveyancing(Trigger.new, trigger.oldmap);
        easyopportunitytriggerhelper.bundle3upsellEPC(Trigger.new, trigger.oldmap);
        easyopportunitytriggerhelper.bundle3upsellMortgage(Trigger.new, trigger.oldmap);
        easyopportunitytriggerhelper.bundle3upselluswitchelec(Trigger.new, trigger.oldmap);
        easyopportunitytriggerhelper.bundle3upselluswitchgas(Trigger.new, trigger.oldmap);
        easyopportunitytriggerhelper.bundle3upselluswitchwater(Trigger.new, trigger.oldmap);
        easyopportunitytriggerhelper.applicanthomebuyerreport(Trigger.new, trigger.oldmap);
        easyopportunitytriggerhelper.applicantutilityswitchgas(Trigger.new, trigger.oldmap);
        easyopportunitytriggerhelper.applicantutilityswitchwater(Trigger.new, trigger.oldmap);
        easyopportunitytriggerhelper.applicantutilityswitchelec(Trigger.new, trigger.oldmap);
        easyopportunitytriggerhelper.applicantremovals(Trigger.new, trigger.oldmap);
        easyopportunitytriggerhelper.applicantgassafetycheck(Trigger.new, trigger.oldmap);
        easyopportunitytriggerhelper.applicantpattest(Trigger.new, trigger.oldmap);
        easyopportunitytriggerhelper.applicantaffiliates(Trigger.new, trigger.oldmap);
    
}
}



part of the class displayed here:
public with sharing class easyopportunitytriggerhelper {

public static void oppbundle1 (list<Easy_Opportunity__c> opps, map<id, Easy_Opportunity__c> oldoppmap) {

list<Easy_Opportunity__c> opplist = new list <Easy_Opportunity__c>();

Id recId = Schema.SObjectType.Easy_Opportunity__c.getRecordTypeInfosByName().get('Residential Sales').getRecordTypeId();

for(Easy_Opportunity__c oppty : opps){



if( (oldOppmap.get(oppty.id).Stage__c != 'Closed Won') && oppty.stage__c == 'closed won'  &&  oppty.name == 'market appraisal' && oppty.recordtypeid == recId){

Easy_Opportunity__c newopp = new Easy_Opportunity__c ();

            newopp.ownerid = oppty.ownerid;
            newopp.name = 'Bundle 1 Opportunity'; 
            newopp.Account_Name__c = oppty.Account_Name__c;
            newopp.CurrencyIsoCode = oppty.currencyisocode;
            newopp.stage__c = 'New';
            newopp.recordtypeid = recId;
            newopp.Contact_Name__c = oppty.Contact_Name__c;
            newopp.Close_Date__c = Date.today().addDays(2);
            

     opplist.add(newopp);

   insert opplist; 


    List<Product__c> Pd = (List<Product__c>) System.Json.deserialize('[{"attributes":{"type":"Product__c"},"Recordtype.name":"Residential Sales","Name":"Easy One","List_Price__c":"111.00","Sold_Price__c":"111.00"}]', List<Product__c>.class);
    for (Product__c eachProd : Pd)
 eachProd.Easy_Opportunity__c = opplist[0].id;
    
insert Pd;

}
}
}

unit test:
 
@isTest
public class easyopportunitytriggerTest 
{

        static testmethod void test_trigger(){
        
Account acct = new Account(Name='Test');


    insert acct;
        

           

contact ct = new contact(firstName='Iain', lastname =  'Banks');

    insert ct;
Id recId = Schema.SObjectType.Easy_Opportunity__c.getRecordTypeInfosByName().get('Residential Sales').getRecordTypeId();
            Easy_Opportunity__c easyOpp = new Easy_Opportunity__c();
            
            
            easyopp.Account_Name__c = acct.id;
            easyOpp.Stage__c = 'New';
            easyOpp.Name = 'Market Appraisal';
            easyOpp.Close_Date__c = system.today();
            easyOpp.currencyisocode = 'GBP';
            easyOpp.Contact_Name__c = ct.id;
            easyOpp.recordtypeid = recid;
            
            // insert all required field;
            insert easyOpp;
            
            product__c pd = new product__c();
            pd.name='easy two';
            pd.Easy_Opportunity__c=easyopp.id;
           
            
            insert pd;

             Test.StartTest(); 
             
                easyOpp.Stage__c = 'Closed Won';
                easyOpp.Opportunity_Rating__c = 'Hot';
                easyOpp.recordtypeid = recid;
                update easyOpp;
                
                easyOpp.Stage__c = 'Closed lost';
                easyOpp.Opportunity_Lost_Reason__c = 'Other';
                easyOpp.Other_Lost_Reason__c = 'dfdf';
                easyOpp.recordtypeid = recid;
                update easyOpp;
                
                 easyOpp.name =  'Bundle 2 Opportunity';
                update easyOpp;
                
                easyOpp.name =  'market appraisal';
                update easyOpp;
                
                easyOpp.name =  'Bundle 3 Opportunity';
                update easyOpp;
                
                easyOpp.name =  'Bundle 1 Opportunity';
                update easyOpp;
                
                easyOpp.name =  'Mortgage & Conveyancy Opportunity';
                update easyOpp;
                
             Test.StopTest();
            
        }

}

 
Hi Everyone,

I have a multiselect picklist with values 1 to 10
I have selected 1, 2, 8 and saved the first record.
For the next record I should not see the values 1, 2, 8 as they are already got selected and saved for the first record.
This needs to be achieved in the modal and not on VF.
hi i have requirement where i have to built visual force page.. my data will be stored in db like followingUser-added image



i want to show my visual force like following

User-added image



i have written some sample code  to dispaly header..
 
public list<String> getagrmnts(){
        m.put('Name','');
        m.put('Driver__c','');
        period.add('Agreement no');
        period.add('Driver');
        headerKeys.add('name');
        headerKeys.add('driver__c');
        list<String> tempStr = new list<String>{};
        for(Agreement1__c a : al){
            flag = 1;
            tempStr.add(a.name);
            tempStr.add(a.driver__c);
            //if(period.indexOf(a.period__c)==-1)
            for(String p: period ){
                if(p == a.period__c){
                    flag = 0;
                }
            }
            if(flag == 1){
                m.put(a.period__c,'');
                headerKeys.add(a.period__c);
                period.add(a.period__c);
            }    
        }
        return period;    
    }

and page code to display header is
<apex:page controller="header">
<apex:pageBlock >
<table>
<tr>
<apex:repeat value="{!agrmnts}" var="c">
<td>
<apex:outputText value="{!c}"></apex:outputText>
</td>
</apex:repeat>
</table>
</apex:page>

please tell me how can i fill data to that table i want to mshow like above
Hi,

I have a @future method Display().
I want to open visualforce page after executing callout code from future method.

@future(callout=true)
public static void display()
{
//callout code
//after this callout code, this method should open vf page
}

I am calling this future method thro' after insert trigger.
  • January 22, 2015
  • Like
  • 0
Hi,
We havesalesforce trigger is written on account object to call a web service async.We have 120 seconds timeout set up in salesforce.
I want to make account uneditable until ,it gets response from web service.
Please suggest how can we achieve this?

 
  • January 22, 2015
  • Like
  • 0
How to pass parakmeters using URLFOR()hi all,

i have a scenario where in i need to prepopulate a field eventId of type text with event object's id passed using URLFOR().
However i get an error saying

Syntax error. Found '[' 

below is my code1 new_url = "{!URLFOR( $Action.Order__c.New, null, [00N11000000srcf=Event.Id])}";

2 window.location.replace(new_url);where  00N11000000srcf is fetched after i right click on text field-->inspect element and copy the id  of the field to be prepopulated

any help is appreciated
Hi,
Could you help me with the problem below. I got the error "No access to entity: Calendar in row 1, column 8", but I didn't know exactly the error.
Is the following syntax ok?
 
IF(Calendar.Year(EZR.Beginn_der_HV__c) = This.Year) { 
  Bestandsentwicklung_CY++; 
}
The field Beginn_der_HV__c includes dates. I want to count the Beginn_der_HV__c if the calendar year from this field is like current year, also I need to count the field if the calendar year from this field is like current year - 2.

Thanks for your help, Sascha
 
public class testfor6_c {

private Id accId {get; set;}
public testfor6_c(ApexPages.StandardController stdcontroller) { 
    accId = stdcontroller.getRecord().Id;

    Bestandsentwicklung_CY = 0;
    Bestandsentwicklung_CY_2 = 0;

    getEZRen();   
}

public Integer Bestandsentwicklung_CY {get; set;}
public Integer Bestandsentwicklung_CY_2 {get; set;}

public void getEZRen() {

List<Einzelrisiko__c> EZRList = [SELECT Beginn_der_HV__c FROM Einzelrisiko__c WHERE Abgangsdatum__c = Null AND Unternehmens_Id_Long__c = :accId]; 

FOR (Einzelrisiko__c EZR : EZRList) { 

    IF(Calendar.Year(EZR.Beginn_der_HV__c) = This.Year) { Bestandsentwicklung_CY++; }
    IF(Calendar.Year(EZR.Beginn_der_HV__c) = This.Year-2) { Bestandsentwicklung_CY_2++; }    

} } }



 
Hi all,
I'm new for salesforce help me please. Why I can't open visualforce page by button.
This is my code

public PageReference onSave(){
        upsert(lstProductService);
        String url = 'Cost_Calculator_2?&CF00NO0000001EtuG_lkid='+theProduct.Id+'&CF00NO0000001EtuG='+theProduct.Name;
        PageReference pref=new PageReference('/'+url);
        return pref;
    }

This is my page.
User-added image

This code in visualforce page.
             <center><apex:commandButton value="Save" action="{!onSave}"/></center>

I want open the another page by visualforce page.
Thank you for ans.

Request please assisst i m stuck on this work fir 2 weeks.

please

I have a group of 3 radio buttons. I want to dynamically check one of the radio button based on some condition. How do I make this work.
<input type="radio" name="optionsRadios" id="" value="option2" checked="if((account.Phone_Type_1__c==account.Preferred_Contact_Type__c),true,false)"
<input type="radio" name="optionsRadios" id="" value="option2" checked="if((account.Phone_Type_2__c==account.Preferred_Contact_Type__c),true,false)"
 <input type="radio" name="optionsRadios" id="" value="option2" checked="if((account.Phone_Type_3__c==account.Preferred_Contact_Type__c),true,false)"


Preferred_Contact_Type__c is a text field
Phone_Type_1__c
Phone_Type_2__c
Phone_Type_3__c

these all r pick list fields with value work , home ,fax
and user enters value in  Preferred_Contact_Type__c
which if matched should select desired radio button

in this only the last radio button is selected 
i want it to be preselected based on condition

 
Hi,

I have written a Trigger where in i am Preventing duplicate Contact on a Child Account when Same contact appears on the Parent account.

trigger Duplicate on Contact (before insert , before update) {

        set<Id> accIds = new set<Id>();
    set<Id> parentIds = new set<Id>();
    
     for(Contact p :trigger.new){
        accIds.add(p.accountId);
}
map<Id,account> parentAccmap = new map<Id,account>([select Id,parentId,recordtypeId from account where Id IN :accIds and parentId!=NULL and recordtypeId='012600000005J5J']); //add Site record type Id here.
    for(account a:parentAccmap.values()){
        parentIds.add(a.parentId);
        }
        map<Id,Contact> parentPrMap = new map<Id,Contact>();
    list<Contact> prParentlist = [select ID,Email,AccountId, Account.recordtypeId from Contact where AccountId IN:parentIds and Account.recordtypeId='012600000005J5I']; //add Customer record type Id here.
    for(Contact pr:prParentlist){
        parentPrMap.put(pr.AccountId, pr);
        }
        for(Contact prr:trigger.new){
        if(prr.email!=null && parentAccmap.containsKey(prr.Accountid) && parentPrMap.containsKey(parentAccmap.get(prr.Accountid).ParentId)){
            if(prr.email == parentPrMap.get(parentAccmap.get(prr.Accountid).ParentId).email){
            String baseUrl = URL.getSalesforceBaseUrl().toExternalForm()+'/02Z/e?parentId=';
string errorMsg = '<a style=\'color:1B2BE8\'href="'+baseUrl+ prr.accountid +'"> Please Create a Contact Role  </a>';
                prr.addError('This Contact already exists.'+ errorMsg,false);
            }
        }
    }
}

Can some one help me with logic or modification to the above trigger so that if that contact is present on any of the Child Accounts of the Parent account, error should be thrown.
  • October 21, 2014
  • Like
  • 0