• Anirudh Singh
  • NEWBIE
  • 399 Points
  • Member since 2014

  • Chatter
    Feed
  • 13
    Best Answers
  • 0
    Likes Received
  • 1
    Likes Given
  • 0
    Questions
  • 69
    Replies
I'm trying to create a button on the object Opportunity Product, The button is a List Button and I want it to update the checkbox of the selected items.

{!REQUIRESCRIPT("/soap/ajax/37.0/connection.js")} 
var opp = new sforce.SObject('OpportunityLineItem'); 
opp.id = "{!OpportunityLineItem.Id}"; 
opp.Use_Calculated_Price__c = 1; 
result = sforce.connection.update([opp]); 
location.reload(true);

It doesn't show any mistake, but only refreshes the opportunity page.
I tryed with diferent values like '1', true, True, TRUE.

Thanks.
A freelance developer left me hanging by not finishing the job. I really need to have this page not include all of the IsChild Events. Most every Event created in our org has invitees, but this makes it very difficult to know which is the parent on this vf page.
This is what I have so far. really hoping someone can help.

<apex:page controller="MeetingBacklogController" tabStyle="Event">
    <apex:sectionHeader title="Event" subtitle="Meeting Backlog" />
    <apex:form id="form">
        <apex:pageBlock >
            <apex:pageBlockButtons >
                <apex:commandButton rendered="{!events.size>0}" value="Save" action="{!save}" reRender="form" status="status" />
                <apex:commandButton value="Refresh" action="{!refresh}" reRender="form" status="status" />
                <apex:actionStatus startText="Updating..." id="status" />
            </apex:pageBlockButtons>

            <apex:pageMessages />
            <apex:pageMessage severity="info" rendered="{!events.size=0}">
                No records found
            </apex:pageMessage>
            <apex:pageBlockTable rendered="{!events.size>0}" value="{!events}" var="event">
                <apex:column headerValue="{!$ObjectType.Event.fields.Set_By__c.Label}" value="{!event.Set_By__c}" />
                <apex:column headerValue="{!$ObjectType.Event.fields.Attendee__c.Label}" value="{!event.Attendee__c}" />
                <apex:column headerValue="{!$ObjectType.Event.fields.Meeting_Progression__c.Label}" value="{!event.Meeting_Progression__c}" />
                <apex:column headerValue="{!$ObjectType.Event.fields.Client_Invite__c.Label}">
                    <apex:inputField value="{!event.Client_Invite__c}" />
                </apex:column>
                <apex:column headerValue="{!$ObjectType.Event.fields.Exec_Invite__c.Label}">
                    <apex:inputField value="{!event.Exec_Invite__c}" />
                </apex:column>
                <apex:column headerValue="{!$ObjectType.Event.fields.Exec_Accepted__c.Label}">
                    <apex:inputField value="{!event.Exec_Accepted__c}" />
                </apex:column>
                <apex:column headerValue="{!$ObjectType.Event.fields.Exec_Tentative__c.Label}">
                    <apex:inputField value="{!event.Exec_Tentative__c}" />
                </apex:column>
                <apex:column headerValue="{!$ObjectType.Event.fields.Meeting_Status__c.Label}">
                    <apex:inputField value="{!event.Meeting_Status__c}" />
                </apex:column>
                                <apex:column headerValue="{!$ObjectType.Event.fields.Location.Label}" value="{!event.Location}" />
                <apex:column headerValue="{!$ObjectType.Event.fields.StartDateTime.Label}" value="{!event.StartDateTime}" />
                <apex:column headerValue="{!$ObjectType.Account.fields.Name.Label}" value="{!event.AccountId}" />
                <apex:column headerValue="{!$ObjectType.Contact.fields.Name.Label}" value="{!event.WhoId}" />
                <apex:column headerValue="{!$ObjectType.Contact.fields.Title.Label}" value="{!relatedRecords[event.WhoId]['Title']}" />
            </apex:pageBlockTable>
        </apex:pageBlock>
    </apex:form>
</apex:page>
Hi All,

Disclaimer: I am a beginner developer and am still working to understand Apex; I have strong Admin experience. Please see my code below:
 
trigger EPS_LeadCycleCreator on Lead(after update)
{
    List<Lead_Cycle__c> LeadCycles = new List<Lead_Cycle__c>();
    
    Set<Id> ownerIds = new Set<Id>();
    for(Lead l : trigger.new)
    {
        Lead oldLead = trigger.oldMap.get(l.Id);
        
        Boolean oldLeadIsNo = oldLead.Status.equals('No');
        Boolean newLeadIsNo = l.Status.equals('No');
        
        Boolean oldLeadIsInactive = oldLead.Trigger_Owner_Active__c == false;
        Boolean newLeadIsInactive = l.Trigger_Owner_Active__c == false;
        
        if((!oldLeadIsNo && newLeadIsNo) || (!oldLeadIsInactive && newLeadIsInactive))
        {
            ownerIds.add(l.OwnerId);
        }
    
    }
    
    Map<Id, User> ownerMap = new Map<Id, User>([ Select Id, ProfileId, Profile.Name From User where Id IN: ownerIDs ]);
    
    for(Lead l : trigger.new)
    {
        Lead oldLead = trigger.oldMap.get(l.Id);
        
        Boolean oldLeadIsNo = oldLead.Status.equals('No');
        Boolean newLeadIsNo = l.Status.equals('No');
        
        Boolean oldLeadIsInactive = oldLead.Trigger_Owner_Active__c == false;
        Boolean newLeadIsInactive = l.Trigger_Owner_Active__c == false;
        
        if((!oldLeadIsNo && newLeadIsNo) || (!oldLeadIsInactive && newLeadIsInactive))
        {
            if(ownerMap.containsKey(l.OwnerId) && ownerMap.get(l.OwnerId).Profile.Name == 'Sales Associate')
            {
                Lead_Cycle__c LeadCycle = new Lead_Cycle__c();
                LeadCycle.Lead__c = l.id;
                LeadCycle.Cycle_Start_Date__c = l.LastTransferDate;
                LeadCycle.Cycle_End_Date__c = system.today();
                LeadCycle.OwnerId = '00560000002VLHw';
            
                LeadCycles.add(LeadCycle);
            }
        }
    
    }   
    insert LeadCycles;
}
 
trigger EPS_OwnerActiveFalseChecker on Lead (before update) 
{
    for (Lead l : Trigger.new)
    {
        if(system.trigger.OldMap.get(l.Id).Owner_Active__c != system.trigger.NewMap.get(l.Id).Owner_Active__c)
        {
            l.Trigger_Owner_Active__c = l.Owner_Active__c;
        }
    }
}

The top trigger attempts to accomplish the following: If a User with a Profile of 'Sales Associate' has its Lead Status change to 'No' from a different value or if the field Trigger_Owner_Active__c changes to False, then create a Record associated to the Lead.

The bottom trigger attempts to copy changes in a formula field into a text field. The formula field is Owner_Active__c which looks to see if the User (Owner of the Lead) is Active, the text field is Trigger_Owner_Active__c. This serves two purposes: 1) To see if the User changes to Active = false OR if the Owner changes to a Queue (Queues cause this field to be marked false).

My issues are as follows:
1. When I change the Lead Owner to a queue, the text field changes with the formula field BUT the new Lead_Cycle__c record is not created
2. When I change the Lead Owner (User) to Active = false, the Trigger_Owner_Active__c field does NOT change with the formula field

Thanks for giving my question consideration,
Elliot
I have a tigger that creates a new record for 4 diffrent fields on Goal Object. It creates 4 new records at one time on a object called Quarterly Goal. This seems smiple...I would like to select a value in a picklist called Fiscal Quarter: Picklist Values Q1,Q2,Q3,Q4. 

Expamlpe:

Object (Goal) > Field (Goal Q1) = Object (Quarterly Goal) > Field (Quarterly Goal = Q1)

Her is my Tigger that I've had help on...a lot of help! Thank You! 
 
trigger CreateGoalSplits on Goal__c (after insert, after update) 
{
    if( trigger.isInsert )
    {
        List<Goal_Split__c> goalSplits = new List<Goal_Split__c>();
        
        for( Goal__c goal : trigger.new )
        {
            if( goal.GoalQ1__c != null )
            {
                Goal_Split__c goalSplit = new Goal_Split__c( GoalAmount__c = goal.GoalQ1__c, ClientOwner__c = goal.ClientOwner__c, AdditionalOwner__c = goal.AdditionalOwner__c, AgencyOwner__c = goal.AgencyOwner__c, GoalNumber__c = goal.Id );
                goalSplits.add( goalSplit );
            }
            
            if( goal.GoalQ2__c != null )
            {
                Goal_Split__c goalSplit =  new Goal_Split__c( GoalAmount__c = goal.GoalQ2__c, ClientOwner__c = goal.ClientOwner__c, AdditionalOwner__c = goal.AdditionalOwner__c, AgencyOwner__c = goal.AgencyOwner__c, GoalNumber__c = goal.Id );
                goalSplits.add( goalSplit );
            }
            
            if( goal.GoalQ3__c != null )
            {
                Goal_Split__c goalSplit = new Goal_Split__c(  GoalAmount__c = goal.GoalQ3__c, ClientOwner__c = goal.ClientOwner__c, AdditionalOwner__c = goal.AdditionalOwner__c, AgencyOwner__c = goal.AgencyOwner__c, GoalNumber__c = goal.Id );
                goalSplits.add( goalSplit );
            }
            
            if( goal.GoalQ4__c != null )
            {
                Goal_Split__c goalSplit =  new Goal_Split__c( GoalAmount__c = goal.GoalQ4__c, ClientOwner__c = goal.ClientOwner__c, AdditionalOwner__c = goal.AdditionalOwner__c, AgencyOwner__c = goal.AgencyOwner__c, GoalNumber__c = goal.Id );
                goalSplits.add( goalSplit );
            }
        }
        
        if( goalSplits.size() > 0 )
            insert goalSplits;
    }
    else if( trigger.isUpdate )
    {
        List<Goal_Split__c> goalSplits = new List<Goal_Split__c>();
        
        List<Goal__c> goals = [ Select Id, AgencyOwner__c, AdditionalOwner__c, ClientOwner__c, (Select AgencyOwner__c, AdditionalOwner__c, ClientOwner__c, Id from Goal_Resources__r) from Goal__c where Id IN: trigger.new ];
        
        for( Goal__c g : goals )
        {
            if( trigger.oldMap.get( g.Id ).AgencyOwner__c != g.AgencyOwner__c
                || trigger.oldMap.get( g.Id ).AdditionalOwner__c != g.AdditionalOwner__c
                || trigger.oldMap.get( g.Id ).ClientOwner__c != g.ClientOwner__c )
            {
                for( Goal_Split__c gs : g.Goal_Resources__r )
                {
                    gs.AdditionalOwner__c = g.AdditionalOwner__c;
                    gs.AgencyOwner__c = g.AgencyOwner__c;
                    gs.ClientOwner__c = g.ClientOwner__c;
                    
                    goalSplits.add( gs );
                }
            }
        }
        
        if( goalSplits.size() > 0 )
            update goalSplits;
    }
}

 
To give you some background, I have a parent object called Concept_Master_Contact__c and child object called Concept_Email__c

 I am trying to write a tirgger that would update the Unique_person ID on Concept_Email__c when it is changed in Concept_Master_Contact__c

Any help with fixing the trigger below will be appreciated. 

Problem: initial term of field expression must be a concrete sobject: List<Concept_Master_Contact>

trigger updateFields on Concept_Email__c (before update) {
    
    //The parent Object
    List<Concept_Master_Contact__c> conmast = new List<Concept_Master_Contact__c>();
    //The child object
    public List<Concept_Email__c> conemail{get;set;}
    
    for (Concept_Email__c obj: trigger.new){
    //if the Unique person ID changes on the parent object, change the person ID on the child object to match the parent object
    If (conemail.Unique_Person_ID__c != conmast.Unique_Person_ID__c){
            conmast.Unique_Person_ID__c = conemail.Unique_Person_ID__c;
        }
    }
    
}
The property and method are public so not sure why I'm getting this error:

User-added image

My Custom Controller:
 
public class MeritusSignupController {


 public Form__c form {get;set;}
 public String formId {get;set;}
 public Account a {get;set;}
 public Contact c {get;set;}
 public String is_new {get;set;}


 public MeritusSignupController()
    {
    
     form= new Form__c();
     form.Applicant_First_Name__c = UserInfo.getFirstName();
     form.Applicant_Last_Name__c = UserInfo.getLastName();
     form.Email__c = UserInfo.getUserEmail();
     a= new account();
     is_new = ApexPages.CurrentPage().getParameters().get('newform');
     formId = ApexPages.CurrentPage().getParameters().get('formid');
     String userId= UserInfo.getUserId();
     c= new contact();
      
     List<Form__c> formList = new List<form__c>();
        if (is_new == 'true')  
        {
            form = new form__c();
            form.Applicant_First_Name__c = UserInfo.getFirstName();
            form.Applicant_Last_Name__c = UserInfo.getLastName();
            form.Email__c = UserInfo.getUserEmail();
        }
    
        else if (formId != null)
        {
            formList = [Select id, Student__r.Name, Student__c, Applicant_First_Name__c,Applicant_Last_Name__c,Email__c from form__c where id =: formid];
        }
    
     upsert form; 
     upsert c;
    }

My VisualForce :
 
<apex:page Controller="SignupController" showHeader="false" sidebar="false" >
<apex:stylesheet value="{!URLFOR($Resource.AppCss)}" />

<body>

<apex:form>

    <div>
      <apex:inputtext value="{!Form__c.Applicant_First_Name__c}" />
    </div>  

    <div>
      <apex:inputtext value="{!Form__c.Applicant_Last_Name__c}" />
    </div>  
    
<apex:commandButton value="Save" action="{!save}" />
 

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


 

With this trigger I am querying each value of a multi-value field and creating a new child record for each value. I am using the field values of the queried record to be field values in the newly created record. One of the values is the Name and the other is the record ID. I now want to take the value of the Vendor__c (which is a lookup field) from that record and plug it into the VendorNEW__c field of the newly created record. Since Vendor__c is a lookup the data type will be an id. But I don't know how to put another value into the map and to carry it down to the newly created record. 

 

trigger AutoCreateSubsServOnContrOv on Policy_Profile__c (After insert, after update) 
        {
           List<Product_Affected_Entry__c> subs = new List<Product_Affected_Entry__c>();
        
               
           List<String> subAccNames=new List<String>();
        
           for (Policy_Profile__c newCont : Trigger.New) 
           {
              if (newCont.Products_Affected3__c != '[]') 
              {
                 // split out the multi-select picklist using a comma delimiter
System.debug('Products_Affected3__c ' + newCont.Products_Affected3__c);

                 String temp = newCont.Products_Affected3__c;
                 temp.normalizeSpace();
                 temp = temp.replace(']','');
                 temp = temp.replace('[','');
                 String[] all = temp.split(',');
                 subAccNames.addAll(all);
System.debug('************************temp'+temp);
                 for (String acctName : all) {
                 subAccNames.add(acctName.normalizeSpace());
System.debug('subAccNames !!! ' + subAccNames); 
                }                

              }
           }
        
           // get the ids for all vendor products and store in a map keyed by name
           Map<String, String, Id> subAccIdsByName=new Map<String, String, Id>();
System.debug('FIRSTsubAccIdsByName='+subAccIdsByName);   
           for (Vendor_Product__c subacc : [select id, Vendor__c,Name from Vendor_Product__c where Name in :subAccNames]) 
                   {
                      subAccIdsByName.put(subacc.Name, subacc.id);
System.debug('subAcc Name and ID=' + subacc.Name +'Id=' + subacc.id + 'Vendor_c=' + subacc.Vendor__c);
                   }
           
System.debug('SECONDsubAccIdsByName=' + subAccIdsByName);
      
           //For each position processed by the trigger, add a new  
        
           //Product_Affected_Entry__c record for the specified Products_Affected3__c.  
        
           //Note that Trigger.New is a list of all the new positions  
        
           //that are being created.  
    
           for (Policy_Profile__c newContract : Trigger.New) 
           {
              if (newContract.Products_Affected3__c != '[]') 
              {
                 // split out the multi-select picklist using a comma delimiter
System.debug('Products_Affected3__c ' + newContract.Products_Affected3__c);
    
                 String temp = newContract.Products_Affected3__c;
                 
                 temp = temp.replace(']','');
                 temp = temp.replace('[','');
                 String[] all = temp.split(',');
        
                 for(String productsonpolicy: all)

                 {
                 
                    productsonpolicy = productsonpolicy.normalizeSpace();
                                      
                    Product_Affected_Entry__c ssoc = new Product_Affected_Entry__c(
             
                            Policy__c = newContract.Id,
                            Vendor_Product__c = subAccIdsByName.get(productsonpolicy), 
                            VendorNEW__c = ***NEED VENDOR__C FIELD OF QUERY RECORD HERE*****
                            
                            Policy_and_Product__c = newContract.Name + '~' + subAccIdsByName.get(productsonpolicy)); 
                           
        
                    subs.add(ssoc);
                 }
              } 
           }
        
           upsert subs Policy_and_Product__c;
        
        }
  • August 31, 2015
  • Like
  • 0
We have a custom object called Opportunty_Product__c that is a lookup to an opportunity. What I wanted to get all of the sibling records of the current opportunity product into a visualforce page where I could select one and link it to the current opportunity product. I am new to apex code and have tried to get this done in a class but all I can get in the page is the opportunity product you clicked the visualforce page from. What am I doing wrong?

Here is my Apex Class:
public with sharing class LinkOfferOpportunityProduct {
    public list <Opportunity_Product__c> OppProdList {get;set;}
    public list <Opportunity_Product__c> OppProdId {get;set;}
    public list <Opportunity_Product__c> LOppProds{get;set;}
    public list <Opportunity_Product__c> OppList {get;set;}
    public list <string> OppIds {get; set;}
    public string selectedOppProd {get;set;}
     public string sSelectedDeal {get; set;}
public LinkOfferOpportunityProduct(){
    try {   
     OppProdId = new list<Opportunity_Product__c> ();
     OppIds = new list<string> ();
    selectedOppProd = ApexPages.currentPage().getParameters().get('id');
     
    OppProdID = [SELECT Id,Opportunity__c FROM Opportunity_Product__c
          WHERE Id =: selectedOppProd];
        
        for (Opportunity_Product__c OppProd : OppProdID) {
      OppIds.add(OppProd.Opportunity__c);
    }
        LOppProds = [SELECT id,Final_Deal_Title_Editable__c,Opportunity__c,Member_Price__c,Start_Date__c FROM Opportunity_Product__c 
                     WHERE id =: OppProdId]; 
  }catch (Exception oException){
            ApexPages.addMessage(new ApexPages.Message(ApexPages.Severity.FATAL, oException.getMessage()));
    }     
    }
public PageReference AddlinkedOffer() {
     PageReference OppProdPageRef;
 Opportunity_Product__c SelectedOppProdId= [SELECT
                  Id,Linked_Deal__c            
                 FROM
                    Opportunity_Product__c
                WHERE
                    Id = :LOppProds];
      SelectedOppProdId.Linked_Deal__c= sSelectedDeal;
            try {   
        update SelectedOppProdId;  
        OppProdPageRef = new PageReference('/' + selectedOppProdId);

    } catch (Exception oException){
            ApexPages.addMessage(new ApexPages.Message(ApexPages.Severity.FATAL, oException.getMessage()));
    }  
    return OppProdPageRef;          
  }   
  }


An here is my visualforce page:

<apex:page controller="LinkedOfferOpportunityProduct">
<apex:form >
<apex:pageBlock >
<apex:PageBlockTable value="{!LOppProds}" var="oppprods" > <apex:column headerValue="Deal Title">
<apex:outputText value="{!oppprods.Final_Deal_Title_Editable__c}" />
</apex:column> <apex:column headerValue="Member Price">
<apex:outputText value="{!oppprods.Member_Price__c}" />
</apex:column> <apex:column headerValue="Start Date">
<apex:outputText value="{!oppprods.Start_Date__c}" />
</apex:column>
<apex:column headerValue="Link Offer to Opportunity Product" >
<apex:commandLink action="{!Addlinkedoffer}" value="Select" id="commandLink" >
<apex:param name="nickName" value="{!oppprods.Id}" assignTo="{!sSelectedDeal}"/>
</apex:commandLink>
</apex:column>
</apex:PageBlockTable>
</apex:pageBlock>
</apex:form>
</apex:page>

 
 Is there a way to hide the recycle bin from the home page component tab?. For the 2015 edition of salesforce as the HTML area for the javascript code is not working

<script>

 var sfdcOnload = self.onload;

 self.onload = function() {

      if (sfdcOnload) sfdcOnload();

      // - hide copyright

     var elements = getElementsByClassName('bPageFooter noTableFooter');
    if (elements.length>0) {
        elements[0].innerHTML = "Your own copyright battle cry";
        elements[0].style.display = 'none'; // or this if you just don't want to see it
    }

 }

</script> 
 
I need SYNTAX to read the SelectedValues (selectList value) 
in picklist (selectoptions) which is in <APEX:REPEAT>
===
objectivetype: "yes, no, Maybe, dontknow"
===
My VF code:
-------------------
<table border="1" width="100%">
<apex:REPEAT value="{!ques}" var="singleQuestion">
<tr>
<td> {!singleQuestion} </td>

<td>
<apex:selectList value="{!Selectedvalues}" size="1">
<apex:selectoptions value="{!objectivetype}" />
</apex:selectList>
</td>
</tr>
</apex:repeat>
</table>
=====================
In Controller:
--------------
public List<String> Selectedvalues{get; set;}


 
I have to move values with in brackets  of string s into map having s1,s3,s4 as keys and 40,98,78 as values.how to do that?

i am trying the following code in workbench.

string s='(s1,40),(s3,98),(s4,78)';
list<string> k=s.replace(')','').replace('(','').split(',');
map<string,string> maps=new map<string,string>();
for(integer i=0;i<k.size();i++){
maps.put('k[i]','k[i++]');
}
system.debug('size of map---------'+ maps.size());

Is there any better way to do this?please let me know?

In workbench the size of map shows 1 when executed.But it is 3.is some thing wrong with my logic. 
I Have a Parent Account object in this i have check box field "No Asset exist". when ever i am trying to check the checkbox it need to show error message if Assert records exist for this Account Object. if no assert are exist for Account no error message need to show . Assert is child of Account. its shoud be bulkify need to work for multiple Accounts

Need achive by using trigger...plese help on this
  • August 26, 2015
  • Like
  • 0
I'm trying to create a button on the object Opportunity Product, The button is a List Button and I want it to update the checkbox of the selected items.

{!REQUIRESCRIPT("/soap/ajax/37.0/connection.js")} 
var opp = new sforce.SObject('OpportunityLineItem'); 
opp.id = "{!OpportunityLineItem.Id}"; 
opp.Use_Calculated_Price__c = 1; 
result = sforce.connection.update([opp]); 
location.reload(true);

It doesn't show any mistake, but only refreshes the opportunity page.
I tryed with diferent values like '1', true, True, TRUE.

Thanks.
I have a number of Acount page layouts driven by Record Types.

Since winter 16, the Custom buttons on these pages that fire VisualForce pages are failing with a "URL No Longer Exists" message. They were working fine before.

The Custom buttons with visualforce on single page layout objects work fine.

The common differentiator (where its failing) is that the URL for the Account is prefixed with MME.xxx.salesforce.com... This MME prefix is not present where the buttons work fine.


The visualforce code being invoked from the custom button is :

<apex:page standardController="Account"

 extensions="GeneratePromissoryNote"
 action="{!autoRun}"
>
  <apex:sectionHeader title="Auto-Running Apex Code"/>
  <apex:outputPanel >
    Error!
  </apex:outputPanel>
</apex:page>

Its probably very obvious, but can anybody point me int he right direction to resolve this ?

Thanks
Hi, 

 I want to make readonly to visualforce page for some profiles in salesforce please suggest me how to make readonly 

  Profile name ( GHC, Program Admin, Finance) Only Progam Admin should be able to editable other profiles must be read only 

Thanks
Sudhir
can't really do something like:
Schema.getGlobalDescribe().get(ObjectName).newSObject() ;
Email manager class 

public class EmailManager {

    public void sendMail(string Address,string subject, string body)
    {
    Messaging.SingleEmailMessage email = new Messaging.SingleEmailMessage();
    string [] toaddress = new string[]{address};
    email.setToAddresses(toaddress);
    email.setSubject(subject);
    email.setPlainTextBody(body);
    }
}


developer console 
EmailManager e = new EmailManager();
e.sendMail('xxx@domain.com','test email', 'test apex');
  • September 05, 2015
  • Like
  • 0
QUESTION: Does anyone know how to get rid of chatter images so it frees free storage space?

a) Our App loads pictures to chatter feed
b) After some use the content storage gets filled to 100%
c) We delete the contents from chatter files (UI) or through APEX code
d) The content files disappear from all views and lists
e) The file storage for the content is still full, no space was freed
f) Whole environments is jammed since nothing can be uploaded anymore
g) We have tried everything to free the space with no luck

This APEX just hides the files and leaves the storage full

delete [select id from contentDocument];

Storage is full
Storage is full
23 files according to storage report
23 files

Only one file visible. Trashcan is empty. And this is the only user in the (dev) environment and it has admin rights.
Only one file visible


Any ideas? Thanks!
A freelance developer left me hanging by not finishing the job. I really need to have this page not include all of the IsChild Events. Most every Event created in our org has invitees, but this makes it very difficult to know which is the parent on this vf page.
This is what I have so far. really hoping someone can help.

<apex:page controller="MeetingBacklogController" tabStyle="Event">
    <apex:sectionHeader title="Event" subtitle="Meeting Backlog" />
    <apex:form id="form">
        <apex:pageBlock >
            <apex:pageBlockButtons >
                <apex:commandButton rendered="{!events.size>0}" value="Save" action="{!save}" reRender="form" status="status" />
                <apex:commandButton value="Refresh" action="{!refresh}" reRender="form" status="status" />
                <apex:actionStatus startText="Updating..." id="status" />
            </apex:pageBlockButtons>

            <apex:pageMessages />
            <apex:pageMessage severity="info" rendered="{!events.size=0}">
                No records found
            </apex:pageMessage>
            <apex:pageBlockTable rendered="{!events.size>0}" value="{!events}" var="event">
                <apex:column headerValue="{!$ObjectType.Event.fields.Set_By__c.Label}" value="{!event.Set_By__c}" />
                <apex:column headerValue="{!$ObjectType.Event.fields.Attendee__c.Label}" value="{!event.Attendee__c}" />
                <apex:column headerValue="{!$ObjectType.Event.fields.Meeting_Progression__c.Label}" value="{!event.Meeting_Progression__c}" />
                <apex:column headerValue="{!$ObjectType.Event.fields.Client_Invite__c.Label}">
                    <apex:inputField value="{!event.Client_Invite__c}" />
                </apex:column>
                <apex:column headerValue="{!$ObjectType.Event.fields.Exec_Invite__c.Label}">
                    <apex:inputField value="{!event.Exec_Invite__c}" />
                </apex:column>
                <apex:column headerValue="{!$ObjectType.Event.fields.Exec_Accepted__c.Label}">
                    <apex:inputField value="{!event.Exec_Accepted__c}" />
                </apex:column>
                <apex:column headerValue="{!$ObjectType.Event.fields.Exec_Tentative__c.Label}">
                    <apex:inputField value="{!event.Exec_Tentative__c}" />
                </apex:column>
                <apex:column headerValue="{!$ObjectType.Event.fields.Meeting_Status__c.Label}">
                    <apex:inputField value="{!event.Meeting_Status__c}" />
                </apex:column>
                                <apex:column headerValue="{!$ObjectType.Event.fields.Location.Label}" value="{!event.Location}" />
                <apex:column headerValue="{!$ObjectType.Event.fields.StartDateTime.Label}" value="{!event.StartDateTime}" />
                <apex:column headerValue="{!$ObjectType.Account.fields.Name.Label}" value="{!event.AccountId}" />
                <apex:column headerValue="{!$ObjectType.Contact.fields.Name.Label}" value="{!event.WhoId}" />
                <apex:column headerValue="{!$ObjectType.Contact.fields.Title.Label}" value="{!relatedRecords[event.WhoId]['Title']}" />
            </apex:pageBlockTable>
        </apex:pageBlock>
    </apex:form>
</apex:page>
Hi all,

today i'm facing some issues with the queueable interface.

This is my use case:
i gave to send an email with a pdf attachment when an object is created.

This is my solution:
When user create a record, a queueable class is instantiated and enqueued in the apex job queue. The queueable class receive the Account as input and than create the PDF and send it by email.

This is my problem:
the generated job stuck in the queue for hours until a System Error is returned.

This is my code:
page to render as pdf
<apex:page showHeader="true" sidebar="true" controller="TestQueueAndPDFCtrl" renderAs="{!renderAs}">	
	<apex:outputText value="test content {!accid}" />
</apex:page>

this is the page controller
public with sharing class TestQueueAndPDFCtrl {
	
	public String accid {get;set;}
	public String renderAs {get;set;}

	public TestQueueAndPDFCtrl() {
		// get account id from parameter and set on the page
		accid = ApexPages.currentPage().getParameters().get('accId');
		renderAs = ApexPages.currentPage().getParameters().get('renderAs');
	}

	public static void sendPdf() {

		/* create an account and then send the id by email */

		Account a = new Account();
		a.Name = 'marco';
		insert a;

		Id job = System.enqueueJob(new TestQueueableWithCallout(a));
	}
}

It has also a static method to enqueue the job.

this is the queueable class
public class TestQueueableWithCallout implements Queueable, Database.AllowsCallouts {
	
	private Account a;

	public TestQueueableWithCallout(Account a) {
		this.a = a;
	}

	public void execute(QueueableContext context) {

		System.debug('queueble started!!!');

		PageReference pdf = Page.TestQueueAndPDF;
		pdf.getParameters().put('accId', a.id);
		pdf.getParameters().put('renderAs', 'PDF');

		Blob b = pdf.getContentAsPDF();
		// Blob b = Blob.valueOf('ciao');

		Messaging.EmailFileAttachment att = new Messaging.EmailFileAttachment();
		att.setFileName('ciao.pdf');
		att.setbody(b);

		Messaging.SingleEmailMessage mail = new Messaging.SingleEmailMessage();
		mail.setToAddresses(new List<String>{'m.****@****.it'});
		mail.setsubject('test');
		mail.setFileAttachments(new List<Messaging.EmailFileAttachment>{att});
		mail.sethtmlbody('body');

		Messaging.sendEmail(new Messaging.SingleEmailMessage[] {mail});

		System.debug('done');
	}
}

In my ORD i enabled the critical update from SUmmer 15, so the getContentAsPDF behave as a callout.

Could you help me with this?
I have a javascript custom button I've created, and I want to go over an Opportunity standard page and get it's section names using a javascript.

Can it be done ? 
Hi All,

Disclaimer: I am a beginner developer and am still working to understand Apex; I have strong Admin experience. Please see my code below:
 
trigger EPS_LeadCycleCreator on Lead(after update)
{
    List<Lead_Cycle__c> LeadCycles = new List<Lead_Cycle__c>();
    
    Set<Id> ownerIds = new Set<Id>();
    for(Lead l : trigger.new)
    {
        Lead oldLead = trigger.oldMap.get(l.Id);
        
        Boolean oldLeadIsNo = oldLead.Status.equals('No');
        Boolean newLeadIsNo = l.Status.equals('No');
        
        Boolean oldLeadIsInactive = oldLead.Trigger_Owner_Active__c == false;
        Boolean newLeadIsInactive = l.Trigger_Owner_Active__c == false;
        
        if((!oldLeadIsNo && newLeadIsNo) || (!oldLeadIsInactive && newLeadIsInactive))
        {
            ownerIds.add(l.OwnerId);
        }
    
    }
    
    Map<Id, User> ownerMap = new Map<Id, User>([ Select Id, ProfileId, Profile.Name From User where Id IN: ownerIDs ]);
    
    for(Lead l : trigger.new)
    {
        Lead oldLead = trigger.oldMap.get(l.Id);
        
        Boolean oldLeadIsNo = oldLead.Status.equals('No');
        Boolean newLeadIsNo = l.Status.equals('No');
        
        Boolean oldLeadIsInactive = oldLead.Trigger_Owner_Active__c == false;
        Boolean newLeadIsInactive = l.Trigger_Owner_Active__c == false;
        
        if((!oldLeadIsNo && newLeadIsNo) || (!oldLeadIsInactive && newLeadIsInactive))
        {
            if(ownerMap.containsKey(l.OwnerId) && ownerMap.get(l.OwnerId).Profile.Name == 'Sales Associate')
            {
                Lead_Cycle__c LeadCycle = new Lead_Cycle__c();
                LeadCycle.Lead__c = l.id;
                LeadCycle.Cycle_Start_Date__c = l.LastTransferDate;
                LeadCycle.Cycle_End_Date__c = system.today();
                LeadCycle.OwnerId = '00560000002VLHw';
            
                LeadCycles.add(LeadCycle);
            }
        }
    
    }   
    insert LeadCycles;
}
 
trigger EPS_OwnerActiveFalseChecker on Lead (before update) 
{
    for (Lead l : Trigger.new)
    {
        if(system.trigger.OldMap.get(l.Id).Owner_Active__c != system.trigger.NewMap.get(l.Id).Owner_Active__c)
        {
            l.Trigger_Owner_Active__c = l.Owner_Active__c;
        }
    }
}

The top trigger attempts to accomplish the following: If a User with a Profile of 'Sales Associate' has its Lead Status change to 'No' from a different value or if the field Trigger_Owner_Active__c changes to False, then create a Record associated to the Lead.

The bottom trigger attempts to copy changes in a formula field into a text field. The formula field is Owner_Active__c which looks to see if the User (Owner of the Lead) is Active, the text field is Trigger_Owner_Active__c. This serves two purposes: 1) To see if the User changes to Active = false OR if the Owner changes to a Queue (Queues cause this field to be marked false).

My issues are as follows:
1. When I change the Lead Owner to a queue, the text field changes with the formula field BUT the new Lead_Cycle__c record is not created
2. When I change the Lead Owner (User) to Active = false, the Trigger_Owner_Active__c field does NOT change with the formula field

Thanks for giving my question consideration,
Elliot
Hello gurus,

the below apex trigger i guess can hit the governor limits and may be be optimized for bulk updates,
Any changes you would recommend? thank you !
---------------------------------------------------------------------------------------------
trigger abc on abc__c (after insert, after update) {
 
    for(abc__c project : Trigger.New)
    {
               List< Project_Task__c> tasklist = new List< Project_Task__c>    (
               [SELECT id, name, IsComplete__c  FROM Project_Task__c
               WHERE (name LIKE '%big deal Call%'     
                                             AND IsComplete__c = FALSE
                                             AND abc__c = :project.id]
               );
 
               for (Project_Task__c task : tasklist)
               {
                              task. IsComplete__c = true;
               }
               update tasklist;
      
   }
}
----------------------------------------------------------------------------------------------------
  • September 02, 2015
  • Like
  • 0
I have a tigger that creates a new record for 4 diffrent fields on Goal Object. It creates 4 new records at one time on a object called Quarterly Goal. This seems smiple...I would like to select a value in a picklist called Fiscal Quarter: Picklist Values Q1,Q2,Q3,Q4. 

Expamlpe:

Object (Goal) > Field (Goal Q1) = Object (Quarterly Goal) > Field (Quarterly Goal = Q1)

Her is my Tigger that I've had help on...a lot of help! Thank You! 
 
trigger CreateGoalSplits on Goal__c (after insert, after update) 
{
    if( trigger.isInsert )
    {
        List<Goal_Split__c> goalSplits = new List<Goal_Split__c>();
        
        for( Goal__c goal : trigger.new )
        {
            if( goal.GoalQ1__c != null )
            {
                Goal_Split__c goalSplit = new Goal_Split__c( GoalAmount__c = goal.GoalQ1__c, ClientOwner__c = goal.ClientOwner__c, AdditionalOwner__c = goal.AdditionalOwner__c, AgencyOwner__c = goal.AgencyOwner__c, GoalNumber__c = goal.Id );
                goalSplits.add( goalSplit );
            }
            
            if( goal.GoalQ2__c != null )
            {
                Goal_Split__c goalSplit =  new Goal_Split__c( GoalAmount__c = goal.GoalQ2__c, ClientOwner__c = goal.ClientOwner__c, AdditionalOwner__c = goal.AdditionalOwner__c, AgencyOwner__c = goal.AgencyOwner__c, GoalNumber__c = goal.Id );
                goalSplits.add( goalSplit );
            }
            
            if( goal.GoalQ3__c != null )
            {
                Goal_Split__c goalSplit = new Goal_Split__c(  GoalAmount__c = goal.GoalQ3__c, ClientOwner__c = goal.ClientOwner__c, AdditionalOwner__c = goal.AdditionalOwner__c, AgencyOwner__c = goal.AgencyOwner__c, GoalNumber__c = goal.Id );
                goalSplits.add( goalSplit );
            }
            
            if( goal.GoalQ4__c != null )
            {
                Goal_Split__c goalSplit =  new Goal_Split__c( GoalAmount__c = goal.GoalQ4__c, ClientOwner__c = goal.ClientOwner__c, AdditionalOwner__c = goal.AdditionalOwner__c, AgencyOwner__c = goal.AgencyOwner__c, GoalNumber__c = goal.Id );
                goalSplits.add( goalSplit );
            }
        }
        
        if( goalSplits.size() > 0 )
            insert goalSplits;
    }
    else if( trigger.isUpdate )
    {
        List<Goal_Split__c> goalSplits = new List<Goal_Split__c>();
        
        List<Goal__c> goals = [ Select Id, AgencyOwner__c, AdditionalOwner__c, ClientOwner__c, (Select AgencyOwner__c, AdditionalOwner__c, ClientOwner__c, Id from Goal_Resources__r) from Goal__c where Id IN: trigger.new ];
        
        for( Goal__c g : goals )
        {
            if( trigger.oldMap.get( g.Id ).AgencyOwner__c != g.AgencyOwner__c
                || trigger.oldMap.get( g.Id ).AdditionalOwner__c != g.AdditionalOwner__c
                || trigger.oldMap.get( g.Id ).ClientOwner__c != g.ClientOwner__c )
            {
                for( Goal_Split__c gs : g.Goal_Resources__r )
                {
                    gs.AdditionalOwner__c = g.AdditionalOwner__c;
                    gs.AgencyOwner__c = g.AgencyOwner__c;
                    gs.ClientOwner__c = g.ClientOwner__c;
                    
                    goalSplits.add( gs );
                }
            }
        }
        
        if( goalSplits.size() > 0 )
            update goalSplits;
    }
}

 

With this trigger I am querying each value of a multi-value field and creating a new child record for each value. I am using the field values of the queried record to be field values in the newly created record. One of the values is the Name and the other is the record ID. I now want to take the value of the Vendor__c (which is a lookup field) from that record and plug it into the VendorNEW__c field of the newly created record. Since Vendor__c is a lookup the data type will be an id. But I don't know how to put another value into the map and to carry it down to the newly created record. 

 

trigger AutoCreateSubsServOnContrOv on Policy_Profile__c (After insert, after update) 
        {
           List<Product_Affected_Entry__c> subs = new List<Product_Affected_Entry__c>();
        
               
           List<String> subAccNames=new List<String>();
        
           for (Policy_Profile__c newCont : Trigger.New) 
           {
              if (newCont.Products_Affected3__c != '[]') 
              {
                 // split out the multi-select picklist using a comma delimiter
System.debug('Products_Affected3__c ' + newCont.Products_Affected3__c);

                 String temp = newCont.Products_Affected3__c;
                 temp.normalizeSpace();
                 temp = temp.replace(']','');
                 temp = temp.replace('[','');
                 String[] all = temp.split(',');
                 subAccNames.addAll(all);
System.debug('************************temp'+temp);
                 for (String acctName : all) {
                 subAccNames.add(acctName.normalizeSpace());
System.debug('subAccNames !!! ' + subAccNames); 
                }                

              }
           }
        
           // get the ids for all vendor products and store in a map keyed by name
           Map<String, String, Id> subAccIdsByName=new Map<String, String, Id>();
System.debug('FIRSTsubAccIdsByName='+subAccIdsByName);   
           for (Vendor_Product__c subacc : [select id, Vendor__c,Name from Vendor_Product__c where Name in :subAccNames]) 
                   {
                      subAccIdsByName.put(subacc.Name, subacc.id);
System.debug('subAcc Name and ID=' + subacc.Name +'Id=' + subacc.id + 'Vendor_c=' + subacc.Vendor__c);
                   }
           
System.debug('SECONDsubAccIdsByName=' + subAccIdsByName);
      
           //For each position processed by the trigger, add a new  
        
           //Product_Affected_Entry__c record for the specified Products_Affected3__c.  
        
           //Note that Trigger.New is a list of all the new positions  
        
           //that are being created.  
    
           for (Policy_Profile__c newContract : Trigger.New) 
           {
              if (newContract.Products_Affected3__c != '[]') 
              {
                 // split out the multi-select picklist using a comma delimiter
System.debug('Products_Affected3__c ' + newContract.Products_Affected3__c);
    
                 String temp = newContract.Products_Affected3__c;
                 
                 temp = temp.replace(']','');
                 temp = temp.replace('[','');
                 String[] all = temp.split(',');
        
                 for(String productsonpolicy: all)

                 {
                 
                    productsonpolicy = productsonpolicy.normalizeSpace();
                                      
                    Product_Affected_Entry__c ssoc = new Product_Affected_Entry__c(
             
                            Policy__c = newContract.Id,
                            Vendor_Product__c = subAccIdsByName.get(productsonpolicy), 
                            VendorNEW__c = ***NEED VENDOR__C FIELD OF QUERY RECORD HERE*****
                            
                            Policy_and_Product__c = newContract.Name + '~' + subAccIdsByName.get(productsonpolicy)); 
                           
        
                    subs.add(ssoc);
                 }
              } 
           }
        
           upsert subs Policy_and_Product__c;
        
        }
  • August 31, 2015
  • Like
  • 0
I have an AFTER INSERT, AFTER UPDATE trigger which Upserts a new record for each value in a multi-value field. It is also putting a value from a field in the current record (Vendor__c) into one of the fields of the newly created records (VendorNewRecord__c). If a new value is ever added to the multi-value field then it will create a new record for that value using the Upsert. I'm using Upsert because I don't want to create duplicate records every time the record is saved.

However, I don't want it to update the records which have already been made. I only want it to use Upsert to make sure it has already created a record for the value in the multi-value field.

Is there a way to use Upsert to only check if there is already a record made, but not actually update it ?

Here is the actual code which I have for this task :
 
trigger AutoCreateSubsServOnContrOv on Policy_Profile__c (After insert, after update) 
        {
           List<Product_Affected_Entry__c> subs = new List<Product_Affected_Entry__c>();


           List<String> subAccNames=new List<String>();

           for (Policy_Profile__c newCont : Trigger.New) 
           {
              if (newCont.Products_Affected3__c != '[]') 
              {
                 // split out the multi-select picklist using a comma delimiter
System.debug('Products_Affected3__c ' + newCont.Products_Affected3__c);

                 String temp = newCont.Products_Affected3__c;
                 temp.normalizeSpace();
                 temp = temp.replace(']','');
                 temp = temp.replace('[','');
                 String[] all = temp.split(',');
                 subAccNames.addAll(all);

                 for (String acctName : all) {
                 subAccNames.add(acctName.normalizeSpace());

                }                

              }
           }

           // get the ids for all vendor products and store in a map keyed by name
           Map<String, Id> subAccIdsByName=new Map<String, Id>();
System.debug('FIRSTsubAccIdsByName='+subAccIdsByName);   
           for (Vendor_Product__c subacc : [select id, Name from Vendor_Product__c where Name in :subAccNames]) 
                   {
                      subAccIdsByName.put(subacc.Name, subacc.id);

                   }



           //For each position processed by the trigger, add a new  

           //Product_Affected_Entry__c record for the specified Products_Affected3__c.  

           //Note that Trigger.New is a list of all the new positions  

           //that are being created.  

           for (Policy_Profile__c newContract : Trigger.New) 
           {
              if (newContract.Products_Affected3__c != '[]') 
              {
                 // split out the multi-select picklist using a comma delimiter


                 String temp = newContract.Products_Affected3__c;
                 //temp.normalizeSpace();
                 temp = temp.replace(']','');
                 temp = temp.replace('[','');
                 String[] all = temp.split(',');

                 for(String productsonpolicy: all)

                 {

                    productsonpolicy = productsonpolicy.normalizeSpace();
System.debug('productsonpolicy in last FOR loop making the NEW records FOR*****'+productsonpolicy);
                    //for(String productsonpolicy: newContract.Products_Affected3__c.split(',')){

                    Product_Affected_Entry__c ssoc = new Product_Affected_Entry__c(


                            Policy__c = newContract.Id,
                            VendorNewRecord__c = newContract.Vendor__c,
                            Vendor_Product__c = subAccIdsByName.get(productsonpolicy), // GET THE SUB ACCOUNT ID BASED ON NAME
                            Policy_and_Product__c = newContract.Name + '~' + subAccIdsByName.get(productsonpolicy)); 


                    subs.add(ssoc);
                 }
              } 
           }

           upsert subs Policy_and_Product__c;

        }

Thank you very much for any help you can give.
  • August 28, 2015
  • Like
  • 0
We have a Add Sample to Sample request button that was working just fine. Now it opens a new window and doesnt populate the samples. What changed? Opened a ticket with sales force and they pretty much said it's your problem. And sent me here.

Today we’re excited to announce the new Salesforce Developers Discussion Forums. We’ve listened to your feedback on how we can improve the forums.  With Chatter Answers, built on the Salesforce1 Platform, we were able to implement an entirely new experience, integrated with the rest of the Salesforce Developers site.  By the way, it’s also mobile-friendly.

We’ve migrated all the existing data, including user accounts. You can use the same Salesforce account you’ve always used to login right away.  You’ll also have a great new user profile page that will highlight your community activity.  Kudos have been replaced by “liking” a post instead and you’ll now be able to filter solved vs unsolved posts.

This is, of course, only the beginning  and because it’s built on the Salesforce1 Platform, we’re going to be able to bring you more features faster than ever before.  Be sure to share any feedback, ideas, or questions you have on this forum post.

Hats off to our development team who has been working tirelessly over the past few months to bring this new experience to our community. And thanks to each of you for helping to build one of the most vibrant and collaborative developer communities ever.