• rohitsfdc
  • SMARTIE
  • 923 Points
  • Member since 2010
  • Salesforce Freenlancer
  • Applikon IT Solutions


  • Chatter
    Feed
  • 34
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 4
    Questions
  • 246
    Replies
Hi ,

I want to convert Lead to opportunity , recordtype should be assign   based on Lead recordtype.
i have two record types for lead and Opportunity, Based on Lead record type i want to convert Lead to opportunity of  Same name of record typt.

can any one help me out for this......


Regards,
sarevsh.
Hi,

Can someone help as i am pretty new to all this...

I want to write a trigger on the task which updates the task status to completed after the oipportunity is set to Closed Won or Closed lost.

This is to basically prevent any closed opportunities which still have open tasks.

Its an if statement of some sort but I need to learn how to do all this



Thanks in Advanced.

Nick

Hi all,

I am having difficulty creating a test class for a trigger I have created. The trigger updates a date/time field every fime a checkbox field is modified. I am unsure how i would create the tesst trigger, any help would be great.

My trigger is:
trigger ControlRoomCheckedTimeTrigger on Match_Day_Check_List__c (before insert, before update) {
    if(Trigger.isInsert){
     for(match_day_check_list__c b: trigger.new){
      b.Steward_Phone_Check_Complete_Last_Mod__c = DateTime.Now();
      b.Radio_Check_Complete_Last_Modified__c = DateTime.Now();
      b.CCTV_Cameras_Checked_Last_Modified__c = DateTime.Now();
    }
  }
  if(Trigger.isUpdate){
        for(match_day_check_list__c b: trigger.new){
            match_day_check_list__c oldb = Trigger.oldMap.get(b.ID);
            
            if(oldb.Steward_Phone_Check_Complete__c != b.Steward_Phone_Check_Complete__c){
                b.Steward_Phone_Check_Complete_Last_Mod__c = DateTime.Now();
            }
            
            if(oldb.Radio_Check_Complete__c != b.Radio_Check_Complete__c){
                b.Radio_Check_Complete_Last_Modified__c = DateTime.Now();
            }
            
            if(oldb.CCTV_Cameras_Checked__c != b.CCTV_Cameras_Checked__c){
                b.CCTV_Cameras_Checked_Last_Modified__c = DateTime.Now();
            }
            
            if(oldb.Turnstile_Checks_Control_Room__c != b.Turnstile_Checks_Control_Room__c){
                b.Turnstile_Checks_Last_Modified_CRoom__c = DateTime.Now();
            }
            
    }
    
}
}

Many thanks.
Create a custom field cancel__c(checkbox) on sales_Order__c  custom object.
Whenever this checkbox gets checked, a trigger should fire and update the Discount percentage field to 50%.
I want to create a vf page in which a new input text field will be generated if you click last field and save it in record. Something like this:
http://jsfiddle.net/jCMc8/8/

Even it is ok if there is a button on clicking it it will create new field. Can anyone help me with that?
Thanks
Hello,
I'm not a developer but have tried to create a visualforce page, that uses a standard controller, that inserts a record. The record inserted is master-detail to the opportunity object in SFDC.

The VF page works and saves the record as desired but I'd like to display a message to the end user that says, "Record Successfully Saved".

I'm afraid I need to create a controller extension to to this, which I do not know how to do. AND, if I have write a controller extension, I'll also have to write a test class, which I also do not know how to do.

Is this a basic request, and if so, could someone help me create the controller extension and test class? Please see below my VF page:


<apex:page standardcontroller="Customer_Survey__c">

<apex:form >
       
 
<apex:pageBlock title="Customer Survey" mode="edit">
      <apex:pageBlockButtons >
        <apex:commandButton action="{!save}" value="Save"/>
        <apex:commandButton action="{!cancel}" value="Cancel"/>
      </apex:pageBlockButtons>
     
      <apex:pageBlockSection title="General" columns="2">
      <apex:inputField value="{!Customer_Survey__c.Opportunity_Name__c}"/>  
      <apex:outputField value="{!Customer_Survey__c.Client__c}"/>
      <apex:outputField value="{!Customer_Survey__c.Opportunity_Owner__c}"/>
      <apex:outputField value="{!Customer_Survey__c.Site__c}"/>
      <apex:outputField value="{!Customer_Survey__c.Close_Date__c}"/>
      <apex:outputField value="{!Customer_Survey__c.CreatedDate}"/>
     
       </apex:pageBlockSection>
     
      <apex:pageBlockSection title="Questions" columns="2">
     
 
     
        <apex:selectList value="{!Customer_Survey__c.Question_1__c}" multiselect="false" size="1"
                label="1.  How important was it to choose a vendor that could take your product through development to commercialization?">
         <apex:selectOption itemValue="--Select Option--" itemLabel="--Select Option--"/>
         <apex:selectOption itemValue="Not at all" itemLabel="1-Not at all"/>
         <apex:selectOption itemValue="Somewhat" itemLabel="2-Somewhat"/>
         <apex:selectOption itemValue="Average" itemLabel="3-Average"/>
         <apex:selectOption itemValue="High" itemLabel="4-High"/>
         <apex:selectOption itemValue="Critical" itemLabel="5-Critical"/>
         <apex:selectOption itemValue="N/A" itemLabel="Not Applicable"/>
      </apex:selectList>
     
    
     
      <apex:selectList value="{!Customer_Survey__c.Question_2__c}" multiselect="false" size="1"
                label="2.  Please rate how your prior experience working with Patheon in the past was an important factor in your decision, if applicable?">
         <apex:selectOption itemValue="--Select Option--" itemLabel="--Select Option--"/>
         <apex:selectOption itemValue="Not at all" itemLabel="1-Not at all"/>
         <apex:selectOption itemValue="Somewhat" itemLabel="2-Somewhat"/>
         <apex:selectOption itemValue="Average" itemLabel="3-Average"/>
         <apex:selectOption itemValue="High" itemLabel="4-High"/>
         <apex:selectOption itemValue="Critical" itemLabel="5-Critical"/>
         <apex:selectOption itemValue="N/A" itemLabel="Not Applicable"/>
      </apex:selectList>
     
     
     
      <apex:selectList value="{!Customer_Survey__c.Question_3__c}" multiselect="false" size="1"
                label="3.  How easy was it to reach Patheon with your original request? ">
         <apex:selectOption itemValue="--Select Option--" itemLabel="--Select Option--"/>
         <apex:selectOption itemValue="Difficult" itemLabel="1-Difficult"/>
         <apex:selectOption itemValue="Not Easy" itemLabel="2-Not Easy"/>
         <apex:selectOption itemValue="Average" itemLabel="3-Average"/>
         <apex:selectOption itemValue="Easy" itemLabel="4-Easy"/>
         <apex:selectOption itemValue="Very Easy" itemLabel="5-Very Easy"/>
         <apex:selectOption itemValue="N/A" itemLabel="Not Applicable"/>
      </apex:selectList>
     
     
     
       <apex:selectList value="{!Customer_Survey__c.Question_4__c}" multiselect="false" size="1"
                label="4.  How was our CDA process?">
         <apex:selectOption itemValue="--Select Option--" itemLabel="--Select Option--"/>
         <apex:selectOption itemValue="Poor" itemLabel="1-Poor"/>
         <apex:selectOption itemValue="Below Average" itemLabel="2-Below Average"/>
         <apex:selectOption itemValue="Acceptable" itemLabel="3-Acceptable"/>
         <apex:selectOption itemValue="Good" itemLabel="4-Good"/>
         <apex:selectOption itemValue="Excellent" itemLabel="5-Excellent"/>
         <apex:selectOption itemValue="N/A" itemLabel="Not Applicable"/>
      </apex:selectList>
     
     
     
      <apex:selectList value="{!Customer_Survey__c.Question_5__c}" multiselect="false" size="1"
                label="5.  How accurate were we in translating your RFP/project requirements into a formal proposal?">
         <apex:selectOption itemValue="--Select Option--" itemLabel="--Select Option--"/>
         <apex:selectOption itemValue="Poor" itemLabel="1-Poor"/>
         <apex:selectOption itemValue="Below Average" itemLabel="2-Below Average"/>
         <apex:selectOption itemValue="Acceptable" itemLabel="3-Acceptable"/>
         <apex:selectOption itemValue="Good" itemLabel="4-Good"/>
         <apex:selectOption itemValue="Excellent" itemLabel="5-Excellent"/>
         <apex:selectOption itemValue="N/A" itemLabel="Not Applicable"/>
      </apex:selectList>
     
    
     
      <apex:selectList value="{!Customer_Survey__c.Question_6__c}" multiselect="false" size="1"
                label="6.  How much did our proposal and subsequent revision turnaround time influence your vendor selection decision?">
         <apex:selectOption itemValue="--Select Option--" itemLabel="--Select Option--"/>
         <apex:selectOption itemValue="Not at all" itemLabel="1-Not at all"/>
         <apex:selectOption itemValue="Somewhat" itemLabel="2-Somewhat"/>
         <apex:selectOption itemValue="Average" itemLabel="3-Average"/>
         <apex:selectOption itemValue="High" itemLabel="4-High"/>
         <apex:selectOption itemValue="Critical" itemLabel="5-Critical"/>
         <apex:selectOption itemValue="N/A" itemLabel="Not Applicable"/>
      </apex:selectList>
     
     
     
      <apex:selectList value="{!Customer_Survey__c.Question_7__c}" multiselect="false" size="1"
                label="7.  How large a factor was facility location in making your final decision?">
         <apex:selectOption itemValue="--Select Option--" itemLabel="--Select Option--"/>
         <apex:selectOption itemValue="Not at all" itemLabel="1-Not at all"/>
         <apex:selectOption itemValue="Somewhat" itemLabel="2-Somewhat"/>
         <apex:selectOption itemValue="Average" itemLabel="3-Average"/>
         <apex:selectOption itemValue="High" itemLabel="4-High"/>
         <apex:selectOption itemValue="Critical" itemLabel="5-Critical"/>
         <apex:selectOption itemValue="N/A" itemLabel="Not Applicable"/>
      </apex:selectList>
     
    
     
      <apex:selectList value="{!Customer_Survey__c.Question_8__c}" multiselect="false" size="1"
                label="8.  How important was the site qualification/technical visit in your vendor selection?">
         <apex:selectOption itemValue="--Select Option--" itemLabel="--Select Option--"/>
         <apex:selectOption itemValue="Not at all" itemLabel="1-Not at all"/>
         <apex:selectOption itemValue="Somewhat" itemLabel="2-Somewhat"/>
         <apex:selectOption itemValue="Average" itemLabel="3-Average"/>
         <apex:selectOption itemValue="High" itemLabel="4-High"/>
         <apex:selectOption itemValue="Critical" itemLabel="5-Critical"/>
         <apex:selectOption itemValue="N/A" itemLabel="Not Applicable"/>
      </apex:selectList>
     
    
     
      <apex:selectList value="{!Customer_Survey__c.Question_9__c}" multiselect="false" size="1"
                label="9.  Please rate how important Patheon’s regulatory history was in making your final decision?">
         <apex:selectOption itemValue="--Select Option--" itemLabel="--Select Option--"/>
         <apex:selectOption itemValue="Not at all" itemLabel="1-Not at all"/>
         <apex:selectOption itemValue="Somewhat" itemLabel="2-Somewhat"/>
         <apex:selectOption itemValue="Average" itemLabel="3-Average"/>
         <apex:selectOption itemValue="High" itemLabel="4-High"/>
         <apex:selectOption itemValue="Critical" itemLabel="5-Critical"/>
         <apex:selectOption itemValue="N/A" itemLabel="Not Applicable"/>
      </apex:selectList>
     
     
      <apex:selectList value="{!Customer_Survey__c.Question_10__c}" multiselect="false" size="1"
                label="10.  Please rate how important price was when making your final vendor selection?">
         <apex:selectOption itemValue="--Select Option--" itemLabel="--Select Option--"/>
         <apex:selectOption itemValue="Not at all" itemLabel="1-Not at all"/>
         <apex:selectOption itemValue="Somewhat" itemLabel="2-Somewhat"/>
         <apex:selectOption itemValue="Average" itemLabel="3-Average"/>
         <apex:selectOption itemValue="High" itemLabel="4-High"/>
         <apex:selectOption itemValue="Critical" itemLabel="5-Critical"/>
         <apex:selectOption itemValue="N/A" itemLabel="Not Applicable"/>
      </apex:selectList>
     
      <apex:selectList value="{!Customer_Survey__c.Question_11__c}" multiselect="false" size="1"
                label="11.  Please rate the negotiation process for legal terms and conditions?">
         <apex:selectOption itemValue="--Select Option--" itemLabel="--Select Option--"/>
         <apex:selectOption itemValue="Poor" itemLabel="1-Poor"/>
         <apex:selectOption itemValue="Below Average" itemLabel="2-Below Average"/>
         <apex:selectOption itemValue="Acceptable" itemLabel="3-Acceptable"/>
         <apex:selectOption itemValue="Good" itemLabel="4-Good"/>
         <apex:selectOption itemValue="Excellent" itemLabel="5-Excellent"/>
         <apex:selectOption itemValue="N/A" itemLabel="Not Applicable"/>
      </apex:selectList>
     
      <br></br>
      <br></br>
      <br></br>
     
      <apex:inputField value="{!Customer_Survey__c.Feedback_Comments_Process_Improvements__c}"/>

  </apex:pageblocksection>

 
    </apex:pageBlock>


</apex:form>

</apex:page>
Hi All,

Since standard salesforce workflow doesn't allow to create eail alerts on events, I have created a custom object named task1__c and created task1 with an Apex trigger to send email alert when an event is created.

Now a new requirement has come up to send an email 2 days after the event is updated.

I am trying to modify the trigger to update the custom object and then use time based workflow on the custom object for email alert. here is my trigger to create new reords. I need help in modifying this trigger to update the custom object records

trigger createtask on Event (after insert) {    
List<Task1__c> t1 = new List<Task1__c>();
    for (Event newEvent: Trigger.New)
         {
                 t1.add (new Task1__c(
                     Name = 'New PD',
                   (text field on task1) Record_Id__c = newEvent.Id,
                    (text field ontask1)Record_Type__c = NewEvent.RecordTypeId,
                    Start__c = newEvent.StartDateTime,
                    Assigned_to__c = newEvent.OwnerId,
                   
                    Appointment_successful__c = newEvent.Appointment_Successful__c,//a custom tik box on events
                    Location__c = newEvent.Location,
                    End__c = newEvent.EndDateTime,
                    Description__c = newEvent.Description,
                 
                    Subject__c = newEvent.Subject,
                    Detail_link__c = 'https://mydomian.my.salesforce.com/' + newEvent.Id )); // to inlcude this detail link in the email alert 
         }
   insert t1;
}

when the user ticks the box Appointment successful an email alert must be generated.
since this is after insert trigger updates on events will not be mapped into custo ibject task1.
please help me to create an update trigger. I am not too sure how to create an update trigger for an unrelated custom object.

your prompt response is greatly appreciated.

thanks in advance.
  • September 30, 2014
  • Like
  • 0
Hi,

Here is my code sample

<apex:page showHeader="false">
	<style>
        html, body {
        width: 100%;
        height: 100%;
        margin: 0;
        padding: 0;
        }
        #form-wrapper {
        width: 30%;
        position:absolute;
        left:35%;
        top:35%;
        padding: 0;
        }
    </style>
	<body id="body" style="background:-webkit-linear-gradient(top,rgb(137,150,160) 0%, rgb(255,255,255) 90%);">
        	<apex:form>
                <div id="form-wrapper">
                    <apex:pageBlock >
                        <apex:pageBlockSection columns="1" >
                            <apex:inputText label="Username" style="margin-left:45%"  />
                            <apex:inputSecret label="Password" style="margin-left:45%" />  
                            <apex:commandButton value="Login" style="margin-left:45%"/>
                        </apex:pageBlockSection>
                    </apex:pageBlock>
                </div>
        	</apex:form>
    </body>
</apex:page>

And this is what I see:

User-added image

Can someone explain to me what I am doing wrong? Thank you!
Hi,

I am new to Apex and I create a way to create a case from a site, which references the custom billing account number field.  But, I can't figure out how to write the test class.  I basically followed this article https://developer.salesforce.com/page/Creating_Custom_Web-To-Case_Forms_Using_Visualforce_and_Sites for the page and class.  But, what would my test class be?

My Class -
@isTest
public class SubmitCaseControllerTest{
static testMethod void SubmitCaseController(){
     // Create the required test data needed for the test scenario.
     // In this case, I need to update an Account to have a Billing Account Number'controller'
     // So I create that Account in my test method itself.
    
     Account testAccount = new Account(name='Test Company Name',Billing_Account_Number__c='CONTROLLER');
     insert testAccount;

     // Verify that the billingState field was updated in the database.
     Account updatedAccount = [SELECT Billing_Account_Number__c FROM Account WHERE Id = :testAccount.Id];
     System.assertEquals('CONTROLLER', updatedAccount.Billing_Account_Number__c);

     // In this case, I need to update a Case to have a BAN ='CONTROLLER'
     // So I create that Case record in my test method itself.
     Case TestC = new Case(Subject='Test Controller Acct Case',Billing_Acct_Number__c = 'CONTROLLER',
     Has_SIM_card_been_activated__c='Yes',What_Colors_are_Displayed__c = 'Black');
     insert TestC;
    
     // Verify that the case field was updated in the database.
     Case updatedCases = [SELECT Subject FROM Case WHERE Id = :TestC.Id];
     System.assertEquals('Test Controller Acct Case', updatedcases.Subject);
    
     confirm() {
     PageReference q = test.confirm();
     PageReference s = Page.SubmitCaseThanks;
     system.assertEquals(q.getURL(), s.getURL());
}
}

Any help is appreciated.
Hi,

I am quering the custom objects records based on ownerid and logindate field. Now i want to query the record based on order by ownerid and order by loginate field.

My requirement is i want to get the records for every user  in ASC order of records for every user.


Can any one help me....


Thanks,
Sarvesh.

Hi, a classic "new to Apex" questions - sorry.

Story is, we have Milestones PM, the package includes Apex which works it's magic for us - seriously quite a good app! :)

We have another unrelated piece of APEX for logging "Previous Owner" on Account Changes, we'd like to deactivate this. 

When we try to deploy the inactive Trigger from Sandbox to Prod there are errors.

A couple are caused by Validation Rules that have "grown" in the Org - not ideal, but we can spin these down to allow deployment and spin them back up.

The Milestone PM Class "Milestone1_repeatCon" is raising errors that I can't resolve though.

To add to it, when using "Run Test" the errors occur in Prod but pass with flying colours in SB :|

The error is "System.AssertException: Assertion Failed: Expected: false, Actual: true

Class.Milestone1_repeatCon.testController: line 340, column 1"

 

Any guidance would be appreciated!

The irony is, we're trying to spin down the Previous Owner APEX to replace with Flow Triggers!!!

 

Contacts have a lookup relationship to a custom Worker__c object.

Whenever a new Worker__c record is created, I want to create an associated (child) Contact.

My code is as follows:

trigger NewContactforWorker on Worker__c (after insert) {
	List<Contact> conList = new List<Contact>;
    for (Worker__c wkr : trigger.new) {
        a = new Contact(Worker__c = wkr.Id, FirstName = wkr.First_Name__c, 
                        LastName = wkr.Last_Name__c, QSAC_external_id__c = wkr.Worker_External_ID__c);
        conList.add(a);
    }
    insert conList;
}

But I get an error in between the second and third lines.  Can anyone help?

Thank you.
  • September 23, 2014
  • Like
  • 0
Trying to create trigger to create a task when a date is filled in.  Here is what i have so far and getting the error above.

 
trigger CreateTaskonAnnualReport on Annual_Report__c (after update) {
    
    List<Task> newTasks = new List<Task>();
        for (Annual_Report__c ar : Trigger.isupdate()){
            //Creating Task to Matt Sutherland when Certificate Date is updated from null to any value, and he was the initial submitter
            if (Trigger.old[ar].Certificate_Date__c != Trigger.new[ar].Certificate_Date__c
Thoughts on why I am getting this error or any ideas to improve?

Thanks,
Seth

Dear all,

I don't manage to have at least 1% code coverage for my trigger , could you help me please?

What it does, From clicktools url, when a contact answers 'Yes' on the Survey, as soon as it is created in Salesforce , 
this triggers looks in the Field Q6_NeedAmcorToContactYou__c, if value is 'Yes', it creates an Event with the following values.

trigger TriggerEventForCustomerToContact on Amcor_Surveys__c (After insert)
{
     set<id> setamcorIds= new set<id>();
For (Amcor_Surveys__c ams : trigger.new)
{
  If(ams.Q6_NeedAmcorToContactYou__c == 'Yes')
  {
     setamcorIds.add(ams.Id);
  }
}

list<Amcor_Surveys__c> listSelectedAmcor= [select Account_ID__r.OwnerId,Contact_ID__c
                                            from  Amcor_Surveys__c
              where id in :setamcorIds];
System.debug('Creating event record');

list<Event> listEventToCreate= new list<Event> ();
for(Amcor_Surveys__c ams :listSelectedAmcor)
{
  //create an event record
  Event ev = new Event();
  Ev.Business_group__c ='Amcor Flexibles Europe & Americas';
  Ev.Whatid = ams.id;
  ev.RecordTypeId='012g00000004ajF';//'Visit Report VOC';
  ev.Type ='Customer Satisfaction Survey';
  ev.DurationInMinutes = 720;
  ev.Ownerid = ams.Account_ID__r.OwnerId;
  ev.whoId =ams.Contact_ID__c;
  ev.Subject ='Customer Satisfaction Survey - Customer contact' ;
  ev.objective__c = 'Improve Relationship';
  //System.debug('************ ' + system.today());
  Date startDate = system.today();
  ev.ActivityDate = startDate;
  ev.StartDateTime = Datetime.newInstanceGmt(startDate.year(), startDate.month(), startDate.day(), 0, 0, 9);
   ev.ActivityDateTime = Datetime.newInstanceGmt(startDate.year(), startDate.month(), startDate.day(), 0, 0, 09);
  Date EndDate = startdate +5;
  System.debug('Attempting to insert...');
  
  listEventToCreate.add(ev);
    }
try{
insert listEventToCreate;
}
catch(Exception e)
{
  System.debug(e.getMessage());
  }
}

Could you write it for me?
Many thanks for your help.

Hi All,

 

   I have problm with Governor limits.

   In for loop we cannot use DML and SOQL quiries ..  But i have used in my issue.

  That issue is Account related opportunity records amount should be add and give the total amount ..

  

Please give me code instead of this ... 

 

 

 

trigger AmountTask on Opportunity (after insert)
{
for(Opportunity varopp:Trigger.new){
Decimal Amount=0;
List<Opportunity> oppbj=[select id,name,Amount from Opportunity where AccountId=:varopp.AccountId];
for(integer i=0;i<oppbj.size();i++){
Amount=Amount+oppbj[i].Amount;
}
//system.debug('----->'+oppbj.size());
Account varacc=[select id,name,Total_Amount__c from Account where id=:varopp.AccountID];
varacc.Total_Amount__c=Amount;
update varacc;
}
}

 

 

 

 

 

Thank you guys....................

hai all,Thanks in advance..

 

I have a small problem,but i could nt understand how to do it.please help me.

I want to redirect to google page only when the record is inserted.here in this code always it is redirecting after clicking on save.if the error message will come means it wont redirect...

 

public class loginfortestController {
public LoginDetailsforTest__c opp{get;set;}
public loginfortestController() {
opp=new LoginDetailsforTest__c();
}

public pagereference save()
{

for(list<logindetailsfortest__C> lt:[select email__C from logindetailsfortest__C where email__c=:opp.email__c limit 1])
{
system.debug(lt);
if(opp.email__c==null||!lt.isempty())
{
ApexPages.Message myMsg = new ApexPages.Message(ApexPages.Severity.FATAL, 'enter another email id');
ApexPages.addMessage(myMsg);
PageReference pageRef = ApexPages.currentPage();
}else{
LoginDetailsforTest__c ldt=new LoginDetailsforTest__c(user_name__c=opp.user_name__c,email__c=opp.email__c);
insert ldt;
}
}
pagereference ref=new pagereference('https://www.google.com');
return ref;
}

}

 

Hi team,

I am totally new in SFDC Development and I have a big issue .
The previous Developer in my company has gone and I don't manage to resolve the redirection myself.
I would be fully grateful if someone could correct this code.

The problem of my users is the following :

" When I create a New task ,I fill in the datas in the form and I click on the save button on New Event page , I would like to be redirected to the Current view task page (URL + task id)
instead of to be redirected to the Account page ."

I don't know anything about coding in Apex so I really need your help...

I have currently a Visualoforce page nammed : TaskRedirect with this code :

<apex:page standardController="Task" extensions="TaskRedirectController" action="{!redirect}">
</apex:page>

            
It is display for a New Task, and below you will find the code of the Apex Class that is called, could you tell me what I should write to be redirect to the URL + Task_id after save??


public with sharing class TaskRedirectController {
    public final Task task;
    public User userData;
    
    public TaskRedirectController(ApexPages.StandardController redirectController)
    { 
        //get the current record
        this.task=(Task)redirectController.getRecord();
        userData = [SELECT Business_Group__c, Business_Unit__c, User_Division__c, User_Subdivision__c FROM User WHERE Id = :UserInfo.getUserId()]; 
    }
    public PageReference redirect(){
        String what_id = ApexPages.currentPage().getParameters().get('what_id');
        String who_id = ApexPages.currentPage().getParameters().get('who_id');
        String Record_Type = ApexPages.currentPage().getParameters().get('RecordType');
        String task_Id = ApexPages.currentPage().getParameters().get('Id');
        String accid = ApexPages.currentPage().getParameters().get('AccountId');
   
       if(accid == null)
           accid ='';
       if(what_id == null)
           what_id = '';
       if (who_id == null)
           who_id = '';
       if (task_id == null)
           task_id = '';
                 
 String str='/00T/e?retURL=%2F001%2Fo&nooverride=1&00N20000001kXCH='+replaceStr(userData.Business_Group__c)+'&00N20000001kXCL='+replaceStr(userData.Business_Unit__c)+'&00N20000001kXCR='+replaceStr(userData.User_Subdivision__c)+'&00N20000001kXCQ='+replaceStr(userData.User_Division__c)+'&what_id='+ what_id +'&who_id='+ who_id;      
      

        PageReference r= new PageReference(str);
        r.setRedirect(true);
        return r;
        
        }
    public String replaceStr(String s){
        if(s==null) s='';
        return s.replace('&', '%26');
    }
    
    public static testMethod void test()
    {
        Task t = new Task();
        Apexpages.Standardcontroller stdController = new Apexpages.Standardcontroller(t);
        TaskRedirectController testClass = new TaskRedirectController(stdController);
        System.assert(testClass.redirect() != null);
        System.assert(testClass.replaceStr(null) != null);
        System.assert(testClass.replaceStr('&') == '%26');
    }    
}


Many thanks for your help.
Best regards,
Ludivine

How to add records access to created  group

Example: $ObjectType.Object__c.Fields.CustomField__c.Label

But, How to retrieve Label of Custom Field in Apex class?

How can i access my salesforce communities in salesforce1 app? Is there an automated way to do that so that my partners wont have to do that by themselves. Please advise.

Thanks in Advance

Rohit

Is there any way, to assign profiles to tabs, pages, classes automatically through dataloader or some other API??

 

My task is i have more than 200 profiles, n i need to assign a vf page to all of them. one way is to go to security-> select profiles from there, but that is a vey long task, as i need to search those profiles from list of profiles. Is there any easier way to achieve that?

 

Thanks in advance,

Rohit

Hi,

i created a child object for contact. In this child contact i am using getter for childContact to retrieve information in visualforce page. the problem is, everytime i add this information to a list, it only displays the latest information entered, not previous values

 

 

<apex:page standardController="childContact__c" extensions="childContact" >
<apex:form >
<apex:pageBlock >
<apex:pageBlockSection >

<apex:inputField value="{!childContac.Date_Graduated__c}"/>
<apex:inputField value="{!childContac.Date_Started__c}"/>
<apex:inputField value="{!childContac.favorite_professor__c}"/>
<apex:inputField value="{!childContac.School_attended__c}"/>
</apex:pageBlockSection>
<apex:pageBlockButtons location="bottom" ><apex:commandButton value="Save" action="{!save}"/>
<apex:commandButton value="Cancel" action="{!cancel}"/>
</apex:pageBlockButtons>
</apex:pageBlock>
<apex:pageBlock >
<apex:pageBlockSection >
<apex:pageblockTable value="{!fetchTable}" var="fetch" >

<apex:column value="{!fetch.Date_Started__c}" />
<apex:column value="{!fetch.Date_Graduated__c}"/>
<apex:column value="{!fetch.favorite_professor__c}"/>
<apex:column value="{!fetch.School_attended__c}"/>
</apex:pageblockTable>
....
....
....

 

and the extention for this is

public with sharing class childContact {

public childContact(ApexPages.StandardController controller) {}

ID id2=apexPages.currentPage().getParameters().get('rid');
List<childContact__c> listContact= new List<childContact__c>();

    public childContact__c childContac {
          get     {
     if(childContac ==null)
        childContac = new childContact__c();
        return childContac ;
                  }
        set;
         }
public PageReference Save() {

childContac.contact__c=id2;

listContact.add(childContac);
return null;
}

public List<childContact__c> fetchTable {
get{
    return listContact;
}
    set;
}}

 

please tell me where am i doing it wrong, or where do i need modification.

 

 

i have a sf site where i calculate a variable. and i want this variable to be displayed in another page in the same salesforce site. how to do that??

 

I m using the following Eclipse version as IDE from force.com project

Eclipse Standard/SDK
Version: Kepler Release
Build id: 20130614-0229

But it is not showning intellisense for objects, not even for the standard objects.. it just diaplay "no proposals"
here is the snapshot for the same
no intellisense

but when I save the code...it connects to the ORG and updates the code in the org if everything is correct else it throw the error..
but there is no intellisense.

Please guide for the setting that are required for this.

Thanks in advance
Sunny

Hi,

I have a time dependent workflow action on a Opportunity to send an email alert 30 days before opportunity close date, if the opportunity amount is greater than 90,000. The email notification is being sent even if the close date of the opportunity is this week. Has any one come across this issue?
Hi

Iam attempting to reduce the number of SOQL's being triggered to avoid the limits.

I currently have two queiries. The first brings back the mailout items and the second brings back the attachements for the mailout items

Get the mailout items
objMailout = [SELECT Id, contact__c, contact__r.Name, recipient_first_name__c, recipient_last_name__c, caps__r.AccountID__c, file_password__c, email_address__c FROM ci_mailout__c WHERE Sent__c = FALSE AND Mailout_name__c = :strTemplate_Initial ORDER BY Policy_count__C Desc LIMIT 50];
Get the attachments for the above mailout items
objAttachment = [SELECT ID, Name, ContentType, body FROM attachment WHERE ParentId = :thisMailOut.Id];
So ... the above works but gets close to the limit for SOQL

So when I try to join the SOQL into 1 I get the following error
A driving SObject type has already been set, all other entity types in the FROM clause must be relationships to the initial object.  The driving object is CI_Mailout__c.
This is the query that I am attempting to use
objMailout = [SELECT Id, contact__c, contact__r.Name, recipient_first_name__c, recipient_last_name__c, caps__r.AccountID__c, file_password__c, email_address__c FROM ci_mailout__c, attachment WHERE ID = :[SELECT PARENTID FROM ATTACHMENT] AND Sent__c = FALSE AND Mailout_name__c = :strTemplate_Initial ORDER BY Policy_count__C Desc LIMIT 50];

Any guidance would be greatly appreciated.

Thanks


 
I have a requirement that the user will select some objects from a list of objects(on a vf page) he has on his org  and i want to fire same trigger on those selected objects individually. Is it possible??
Does anyone have a solution for this?
Hi all,

I have 2 objects: Claim__c and intake__c
Whenever a new claim is created i need to map all values of claim to intake.All values are getting mapped except the recordtype.Can anyone please tell me how to map recordtype from claim to intake 
Hi,

I have a picklist(Multiselect) field, userPkList, that contains a list users in the format of "LastName, FirstName". Each value that is select is separated by a semicolon and the very last entry does not contain a semicolon. 

Example (LastName, FirstName) 1:
 "Schmo, Joe; Allen, Bary; Queen, Oliver"

Example (LastName, FirstName) 2:
"Queen, Oliver, Allen, Bary; Schmo, Joe; Last1, First1; LastAbc, FirstAbc"

I need help in figuring out a way to parse this picklist (multiselect) field so that I can pull each individual Last and First name and then run a query to get the user record associated to that user. I cannot figure out a good way to do this.

Example of desired logic:

//get userPkList values into a string
//parse string so i can separate all the values based on the semicolon (;) so that i now have a list<string> that is in the format of "lastName, FirstName" per record in the list<string>
//for every string in the list<string> I am going to split the string to get first and last name
//then insert first + ' ' + last into a separate List<String>
//using the new List<String>, obtain all the users in the systems.
 
Greetings all, I am running into the Too Many SOQL queries issue when running a test for this apex class. The testregistrations component passes but the mypage_test fails.

Any thing, I may need to adjust here.
 
public class eventsControllerTests {

static testMethod void myPage_Test()
  {
  //Test converage for the myPage visualforce page
  PageReference pageRef = Page.Events_Home;
  Test.setCurrentPageReference(pageRef);
  // create an instance of the controller
  eventsController myPageCon = new eventsController();
  //try calling methods/properties of the controller in all possible scenarios to get the best coverage.

  myPageCon.Setup();
  String efSetupPage = myPageCon.Setup().getUrl();
  System.assertEquals('/apex/EventsSuccess',efSetupPage);

  myPageCon.closePopupOK();

  }
  
    static testMethod void testRegistrationsTrigger(){
        
        //First, prepare 200 contacts for the test data
        
        String contactLastName = 'Apex';
        String contactFirstName = 'Joe';
        String contactTitle = 'Manager';
        Contact ct = new Contact(lastname=contactLastName, firstname=contactFirstName, title=contactTitle);
        insert ct;
        
        ct = [SELECT Name, Title from Contact WHERE Id = :ct.Id];
        
        Event__c ev = new Event__c(name = 'My Event');
        insert ev;

        Event_Registration__c reg = new Event_Registration__c(Contact__c=ct.Id,Event__c=ev.Id);
        insert reg;

        reg = [SELECT Name_on_Badge__c, Title_On_Badge__c from Event_Registration__c WHERE Id = :reg.Id];
        System.assertEquals(ct.Name, reg.Name_on_Badge__c);
        System.assertEquals(ct.Title, reg.Title_on_Badge__c);

           
    }   
}

 
There is a picklist field on a VF page, after clicking on new button once I select a picklist value in the field, how do I fetch the value, before it is saved in the database. I need to use this fetched value to populate another field before the record is saved.
Hi ,

I want to convert Lead to opportunity , recordtype should be assign   based on Lead recordtype.
i have two record types for lead and Opportunity, Based on Lead record type i want to convert Lead to opportunity of  Same name of record typt.

can any one help me out for this......


Regards,
sarevsh.
Hi,

Can someone help as i am pretty new to all this...

I want to write a trigger on the task which updates the task status to completed after the oipportunity is set to Closed Won or Closed lost.

This is to basically prevent any closed opportunities which still have open tasks.

Its an if statement of some sort but I need to learn how to do all this



Thanks in Advanced.

Nick

Hi all,

I am having difficulty creating a test class for a trigger I have created. The trigger updates a date/time field every fime a checkbox field is modified. I am unsure how i would create the tesst trigger, any help would be great.

My trigger is:
trigger ControlRoomCheckedTimeTrigger on Match_Day_Check_List__c (before insert, before update) {
    if(Trigger.isInsert){
     for(match_day_check_list__c b: trigger.new){
      b.Steward_Phone_Check_Complete_Last_Mod__c = DateTime.Now();
      b.Radio_Check_Complete_Last_Modified__c = DateTime.Now();
      b.CCTV_Cameras_Checked_Last_Modified__c = DateTime.Now();
    }
  }
  if(Trigger.isUpdate){
        for(match_day_check_list__c b: trigger.new){
            match_day_check_list__c oldb = Trigger.oldMap.get(b.ID);
            
            if(oldb.Steward_Phone_Check_Complete__c != b.Steward_Phone_Check_Complete__c){
                b.Steward_Phone_Check_Complete_Last_Mod__c = DateTime.Now();
            }
            
            if(oldb.Radio_Check_Complete__c != b.Radio_Check_Complete__c){
                b.Radio_Check_Complete_Last_Modified__c = DateTime.Now();
            }
            
            if(oldb.CCTV_Cameras_Checked__c != b.CCTV_Cameras_Checked__c){
                b.CCTV_Cameras_Checked_Last_Modified__c = DateTime.Now();
            }
            
            if(oldb.Turnstile_Checks_Control_Room__c != b.Turnstile_Checks_Control_Room__c){
                b.Turnstile_Checks_Last_Modified_CRoom__c = DateTime.Now();
            }
            
    }
    
}
}

Many thanks.

We have code created by consultant that allows us to have a product record type of Package.  When a user selects a package from the product list.  They can then unbundle it on the opportunity.  When they do this, it removes the package, inserts the individual products, and adds the configuration elements associated with the products.  This has worked for years until we created and started using price books.  Now we get the following error when we try to unbundle the package:

 

System.DmlException: Insert failed. First exception on row 0; first error: FIELD_INTEGRITY_EXCEPTION, field integrity exception: PricebookEntryId (pricebook entry is in a different pricebook than the one assigned to the opportunity): [PricebookEntryId]

 

Class.ProductPackageUnbundle.unbundle: line 95, column 1

 

I have no APEX background but it appears that it is always trying to use the Standard Price book.  However, if I use the standard price book, I still get the error when I try to unbundle.  Any help anyone can provide as to what needs to be changed in the code would be greatly appreciated!

 

Here is the code:

 

public class ProductPackageUnbundle {
/*
  Onclick of Unbundle button on Opportunity Products related list
  Look for all opportunity line items with Record type of "Package"
  look to Master_Package_Product__c and insert products related and delete Package record
  use Selling amount from Package record if it is not null
  Create Configurtion elements using the default values.
  

 
*/
    public ProductPackageUnbundle(ApexPages.StandardController stdController) {
            
    }
    
    public final opportunity oppty = [select id,name,pricebook2id,currencyisocode from opportunity where id = :apexpages.currentpage().getparameters().get('id')];
    public final pricebook2 pb2 = [select id,name from pricebook2 where name = 'Standard Price Book'];
    public pagereference unbundle(){
    
      
      string sellingprice;
      //Select all opportunity line items that have a record type of "Package"
      recordtype rtype = [select id from recordtype where name = 'Package' and SobjectType='Product2' limit 1];
      if (rtype.id != null){
        system.debug('recordtype'+rtype.id);
      //selects all line items for opportunity that have record type of package
      list<opportunitylineitem> opliNew = [select id,pricebookentry.Product2Id,quantity from opportunitylineitem where pricebookentryid in (select id from pricebookentry where product2.RecordTypeId = :rtype.id) and opportunityid = :oppty.id];  
      
      if(opliNew.size()!=0){
        set<id> packageID = new set<id>();
        map<id,double> opliQty = new map<id,double>();
        for (opportunitylineitem opliLoop : opliNew){
          packageID.add(opliLoop.pricebookentry.product2id);
          opliQty.put(opliLoop.pricebookentry.product2Id,opliLoop.Quantity);  
        }
        
        list<master_package_product__c> mpp = [select id,name,product__c,package__c,master_configuration_element__c,package__r.name from master_package_product__c where package__c in :packageID and product__c != null];
        system.debug('MPP'+mpp);
        if(mpp.size()>0){
        // Loop through the records and create opportunity line items.
        set<string> mppPackageProduct = new set<string>();
        set<id> mppProduct = new set<id>();
        map<id,id> mppPackage = new map<id,id>();
        map<id,string> mppPackageName = new map<id,string>();
        for (Master_Package_Product__c mppLoop : mpp){
          mppProduct.add(mppLoop.product__c);
          mppPackageProduct.add((''+mppLoop.package__c + mppLoop.product__c));
          mppPackageName.put(mppLoop.package__c,mppLoop.package__r.name);
        }
        system.debug('mppProduct'+mppProduct);
        list<pricebookentry> pbe = [Select id,product2.Name, product2.description,product2.family,product2.Product_Solution__c,product2.Product_Category__c,product2.id,product2.type__c From pricebookentry Where product2.id in :mppProduct and isactive = true  limit 1000];
        // add pricebook entry to map used when looping through packages
        map<id,pricebookentry> pbeMap = new map<id,pricebookentry>();
        for (pricebookentry pbeLoop : pbe){
          pbeMap.put(pbeLoop.product2.id,pbeLoop);  
        }
        system.debug('PBEMAP'+pbeMap);
        list<opportunitylineitem> opliProduct = new list<opportunitylineitem>();
        string tempPackage;
        string tempProduct;
        
        for (string mppLoop2 : mppPackageProduct) {
              if(mppLoop2.length()==36){
                tempPackage = mppLoop2.substring(0,18);
                tempProduct = mppLoop2.substring(18,36);
              }else{
                tempPackage = '';
                tempProduct = '';
              }
              
              if(pbeMap.get(tempProduct)!=null){
                pricebookentry pbeTemp = pbeMap.get(tempProduct);
                  opportunitylineitem opliTemp = new opportunitylineitem();
                     system.debug('PBETEMP'+pbeTemp);
                  opliTemp.pricebookentryid=pbeTemp.id;
                
                //opliTemp.pricebookentryid=pbeLoop.Id;
                opliTemp.opportunityid=oppty.id;
                // for product type of service use qty from Original package
                //changed code to set qty to 1 except for Service with Qty other than 1 011711 DPC
                if(pbeTemp.product2.type__c == 'Service' && opliQty.get(tempPackage)!=null){
                  opliTemp.quantity = opliQty.get(tempPackage);
                  } else {
                  opliTemp.quantity = 1;
                }
                opliTemp.unitprice=0;
                if(mppPackageName.get(tempPackage)!= null){
                  opliTemp.Description = '' + mppPackageName.get(tempPackage);
                }
                opliTemp.OP_SFDC_ID__c = tempPackage;
                opliProduct.add(opliTemp);
          }
            }
            if(opliProduct.size()>0){
              insert opliProduct;
              //create Product Configuration Elements
              productPackageElements ppe = new productPackageElements();
              boolean fromPackage = true;
              string successCode = ppe.CreateElements(opliProduct, fromPackage);
              
              
              // Update the Percentage complete on Create
              productPackagePercentCalc pppc = new productPackagePercentCalc();
              pppc.updatePercentage(opliProduct);
              system.debug('\n\nDELETEOPLINEW'+opliNew);
              delete opliNew;
            }
        } else {
          //Error there should be products for packages
           ApexPages.addMessage(new ApexPages.message(ApexPages.severity.ERROR,'A package you selected has no products Call your Salesforce Administrator'));
        }
        //Lookup all related products from Master_Package_product
          
        
        
        
        
        PageReference opptyPage = new ApexPages.StandardController(oppty).view();
        opptyPage.setRedirect(true);
        return opptyPage;
      } else {
       ApexPages.addMessage(new ApexPages.message(ApexPages.severity.ERROR,'No Packages to Unbundle'));
       return null;
      }
      
      
    //End of Package code if statement
    }
      
      
      
    return null;  
    }
  public pagereference back(){
    //Sends the user back to the opportunity page
    PageReference opptyPage = new ApexPages.StandardController(oppty).view();
        opptyPage.setRedirect(true);
        return opptyPage;
  }


}