• SalesFORCE_enFORCEr
  • SMARTIE
  • 1752 Points
  • Member since 2011
  • Tech Lead
  • Accenture

  • Chatter
    Feed
  • 54
    Best Answers
  • 0
    Likes Received
  • 1
    Likes Given
  • 2
    Questions
  • 605
    Replies
Our developers have created a visualforce webpage, however, it is behind our single sign-on implementation for our Salesforce production environment. We want this visualforce page to be behind one of our community single sign-ons instead. This is because the SAML attributes passed in our community single sign-ons are different from our production environment of Salesforce and the users that need to access this visualforce page are community license users. What needs to happen in order to make this possible?

Hi guys! I've written my first trigger, which works in my sandbox, but I can't successfully write a test for it.  The field that it filters on is a read only formula field.  Any help would be greatly appreciated!
Thanks much!

trigger accountRankings on Account(after insert, after update, after delete){

for(Account acc : trigger.new)
{
//checking if the value is changed
if(acc.VAROrderPointsYTD__c != Null && (trigger.isInsert || (trigger.newMap.get(acc.id).VAROrderPointsYTD__c != trigger.oldMap.get(acc.id).VAROrderPointsYTD__c)))
{
break;
}
else return;
}

//rank top 100 accounts for more accounts change the row limit
List<Account> accounts = [Select VAROrderPointsYTD__c, Point_Ranking__c from Account Where RecordType.Name = 'Richmond VAR' ORDER BY VAROrderPointsYTD__c DESC limit 100];

Integer rank = 1;
for (Account account : accounts)
{
account.Point_Ranking__c = rank;
rank++;
}
update accounts;
}
 

 

Can someone help me to rewrite this trigger so that I do not have a select statement in my for loop?
Is this possible or is my trigger ok? It does work, but I thought having a select statment in my loop is bad.
trigger MostRecentCenter on Procedure__c (before insert, before update) {
   try{           
            
           Set<Id> procIds = new Set<Id>();
           Set<Id> caseIds = new Set<Id>();
               
               for(Procedure__c proc : Trigger.New)
               {                 
                   if(proc.CreatedDate != null) 
                   { 
                       procIds.add(proc.LastModifiedById);  
                       caseIds.add(proc.Case__c);                      
                   }                        
               }                        
               
              Map<string, Procedure__c> procMap = new map<string, Procedure__c> ( [SELECT CenterID__c, Center__c from Procedure__c 
               where LastModifiedById IN: procIds Order by CreatedDate Desc] );
     

              Map<string, Case> caseMap = new map<string, Case> ( [SELECT Id, Most_Recent_Center__c FROM Case WHERE Id IN: caseIds] );  
                         
                 for(Procedure__c pd: trigger.new) 
                 {                    
                    if(procMap.containsKey(pd.id)) 
                    {                 
                      
                        Id centerID = (Id)procMap.get(pd.id).Center__c;
                        Case cs = (Case)[SELECT Id, Most_Recent_Center__c FROM Case WHERE Id = :pd.Case__c];
                        cs.Most_Recent_Center__c = centerID;
                        update cs;                      
                                                               
                    }       
                }  
                
          //  }    //End of trigger.isBefore
        
    }catch(Exception e){
       //Package suspended, uninstalled or expired, exit gracefully.
       System.debug('MostRecentCenter');
    }
    
}

Thnaks,
Keith.
I am receiving a Cover Coverage Failure error (0%) when attempting to deploy my Apex Class, Test Class, and VisualForce Page to production.  My code tested 100% coverage in Sandbox.  The error is on testPageRef method.  The error I am receiving is "System.DmlException: Insert failed. First exception on row 0; first error: REQUIRED_FIELD_MISSING, Required fields are missing: [Source__c]: [Source__c] 
Stack Trace: Class.expressControllerTest.testPageRef: line 9, column 1."  Any help would be appreciated!

Here is my Test Class:
@isTest
public class expressControllerTest {

public static testMethod void testPageRef() {

    Account acc = new Account(Name='Abce');
    insert acc;
    Program__c prg = new Program__c(Account__c=acc.Id);
    insert prg;
    Payment_Schedule__c pa = new Payment_Schedule__c();
    // TODO: Populate required Opportunity fields here
    pa.Name='test sfdc';
    pa.Program_Master__c = prg.Id;
    insert pa;
    
    
    PageReference pref = Page.Payment_Schedules; 
    pref.getParameters().put('id', prg.id);
    ApexPages.StandardController sc= new ApexPages.StandardController(prg);
    expressController exp = new expressController(sc);
    System.assert(null == exp.newPayment_Schedule());    
    System.assertNotEquals(null, exp.getheaders());
    
    System.assertNotEquals(null, exp.getpaymentschedules());
    
    System.assertEquals(null, exp.saveChanges());
}
}
Here is my Controller:
public class expressController {
  
  // Constructor
 public expressController(ApexPages.StandardController controller) {
  this.prog = (Program__c)controller.getSubject();
     this.schedules = [ SELECT 
      ps.Date_Due__c, 
      ps.Amount_Due__c, ps.Descriptions__c, ps.Date_From__c, 
      ps.Date_To__c, ps.Paid__c, ps.Id, ps.CreatedById,
      ps.Program_Master__c FROM Payment_Schedule__c ps where ps.program_Master__c = :prog.id ];
 }
 
 // Action Method called from page button
 public pagereference saveChanges() { 
  upsert this.schedules;
  return null;
 }
 
 // Action Method called from page link
 public pagereference newPayment_Schedule() { 
  payment_schedule__c ps = new payment_schedule__c();
  ps.program_master__c =this.prog.id; 
  schedules.add(ps);
  return null;
 }
 
 // public Getter to provide table headers 
 public string[] getheaders() { return new string [] 
  {'Date Due','Amount Due','Descriptions', 'Date From',
   'Date To','Paid'} ; }
 
 // public Getter to list payment schedules
 public payment_schedule__c[] getpaymentschedules() { 
  return this.schedules; 
 } 
 
 // class variables
 Program__c prog;
 payment_schedule__c[] schedules; 
}


 
Hello, 

I have rule that should trigger a field update, but my rule is only firing off when the checkbox is unchecked. What can I do to ensure that if the box is unchecked and gets checked or if the box is already checked and gets unchecked, it will trigger my field update. 

Here is my formula: 
 
IF( Maintenance__c,FALSE,TRUE)
The above rule only triggers when the box is unchecked 
 
Hello all, I created this button on the Quote object to create QuoteLineItems but it's not working. Below is the code BUT please see my note below the code for some clarification:

{!REQUIRESCRIPT("/soap/ajax/34.0/connection.js")} 

var pricebookid = "01s60000000AaPr"; 
var quoteId = "{!Quote.Id}"; 
var quoteQuery = sforce.connection.query("Select Id, Name FROM Quote WHERE Id='" + quoteId + "'"); 
var quotyResult = quoteQuery.getArray("records"); 
quotyResult[0].Pricebook2Id = pricebookid; 
var updatequotyResult = sforce.connection.update([quotyResult[0]]); 


var result = sforce.connection.query("Select Id,Name,HE__c,HE_Qauntity__c,Price_Book_Entry_ID__c From Product2 Where HE__c = TRUE"); 
var records = result.getArray("records"); 

var CreateRecords=[]; 

if(records[0]==null) 
alert('No Product Set is Retrieved!'); 
for(var i=0;i<records.length;i++) 

var linky=new sforce.SObject("QuoteLineItem"); 
linky.QuoteID = '{!Quote.Id}'; 
linky.PriceBookEntryId = records[i].Price_Book_Entry_ID__c; 
linky.Quantity = records[i].HE_Qauntity__c; 
linky.UnitPrice = 1; 
linky.Quoting_Tool__c = 1; 
CreateRecords.push(linky); 


result=sforce.connection.create([CreateRecords]); 
alert(result); 


window.location.reload();


// The code works fine if I create them one by one within the loop but I wanted to create them at once from an array. For example, if I put 

result=sforce.connection.create([linky]);

in the loop it works fine but slow. That's whay I wanted to go the other way around to create them at once from an array. Please help. 
  • June 12, 2017
  • Like
  • 0
Hi All,

I need a validation rule for a custom object with multiple record types.  Only 2 custom profiles can move a custom stage field to a value of "Complete" (regardless of record type) and 1 custom profile can move the same custom stage field to a value of "Complete" for only 1 of the record types (there are 10+).

I wanted to try to leverage a custom permission at the profile level rather than have a large block of hard coded profile ids and record type names so I started with:

ISPICKVAL(Custom_Stage_Field__c , "Complete") && 
NOT($Permission.Custom_Permission_Name)

This is fine for the first use cases (2 profiles regardless of record type) where the custom permission is enabled however the third custom profile should only move the custom stage field to complete for 1 specific record type, not all. I am sure this just needs to be updated with an OR statement for the last profile and the specific record type but I am not having any luck.  Any ideas would be great!  If anyone needs more info let me know.  Thanks!

 
I am working in the Lightening Experience for Closers trail and cannot close the opportunity because there is not a "closed" stage to choose from.  The stages seem to end at Needs Analysis.  What am I doing wrong?
Hello,

I have added a custom button in the case detail view that sets certain fields (like status to closed). I can close this tab also automatically. However, the main service console list doesn't refresh (the case is still on the old status). If I manually refresh the list (hit the refresh button), the updated data displays. How can I automatically refresh the main service console list ? I'm not using a VF page, only a custom button on the case detail view.

Thanks.

Marco.
Hi guys, I'm new to Salesforce Open CTI integration, I just wanna ask about the call center definition file,
Is every user can access the call centers or only certain users can access those? 
If so, what access right do they need to access the call centers? 
 
I'm thinking if every user can create or import their own Call Center definition File. 

I hope you can help me about this guys. Thank you.
Hi,
I'd like to develop a connector between the platform our company develops and Salesforce so our customers who are also using Salesforce will need to perform less work.
The main user case: user changes some data on our platform and we'll push it to their salesforce platform/tenant and changes done on their salesforce platform/tenant will be pushed into our platform.

Do I need my app/connector to be published in the AppExchange or can we develop it and have our customers install it using a link/package (or similar method not invlolving the AppExchange)?

Thanks,
David
Once an opp enters one of three stages, I want the close date to lock. Does anyone have an idea on how to do this?

 For example:

If an opportunity's stage = Awarded - Written, Awarded - Signed, or Awarded - LOI, I do not want the close date to be editable. 
Assigining permission sets by apex trigger
Requirement : There are some fields on the object , we need to grant permissions to edit  based on the picklist values.( i have written validations rules at first but didnt work)
Scenerio:I ve made all the fields of the object read only in Profile. then created permission set to the fields for edit permission. now based on the profile name I want to assign the same permission set to the user though the trigger.but it is not getting assigned. kindly assist what changes should be done?

Trigger Attached

trigger PSA_on_WO on Service_Order__c (before update)
    {
    if(Trigger.isBefore)
    {
      if(Trigger.isUpdate)
      {
          for ( Service_Order__c wo : trigger.new)
             {
                  id id1 = userinfo.getUserId();
                 id id2 = userinfo.getProfileId();
                String pf=[Select Id,Name from Profile where Id=:id2].Name;
              
              PermissionSetAssignment[] psa1 = new List<PermissionSetAssignment>();

              system.debug('profile ----> '+pf);
              system.debug('id1 ----> '+id1);
              system.debug('order status--->'+wo.Order_Status__c);
              system.debug('order type--->'+wo.Order_Type__c);
                  if(wo.Order_Status__c.equalsIgnoreCase('Draft') 
                           && wo.Order_Type__c.equalsIgnoreCase('FS'))
                 {
                       if(pf=='profile1' || pf == 'profile2' || pf=='profile3')
                    {
                         PermissionSetAssignment psa = new PermissionSetAssignment(PermissionSetId = '0PS3C0000004GLCWA2',AssigneeId = id1);
                 psa1.add(psa);        
                                   system.debug('permission set id----->' +psa.PermissionSetId);
                          system.debug('assignid id----->' +psa.AssigneeId);
                    }
                    else if(pf=='profile4')
                    {
                    PermissionSetAssignment psa = new PermissionSetAssignment(PermissionSetId = '0PS3C0000004GLW',AssigneeId = id1);
                     psa1.add(psa); 
                    }  
              
                   }
             insert psa1;
        }
    }
    }
}
<apex:page controller="clsAccountControl" >

<apex:form >
        <apex:pageBlock title="Account Details" >
            <apex:pageBlockTable value="{!acclist}" var="a" id="mid" >
            
                <apex:column value="{!a.Name}" headerValue="Account Name" />
                
                 <apex:column value="{!a.OwnerId }" headerValue="Owner" />
                <apex:column value="{!a.Custom_Emaail__c }" headerValue="Email" />
                
                <apex:column value="{!a.BillingCity }" headerValue="BillingCity " />
                
            </apex:pageBlockTable>
           
        </apex:pageBlock>
        
    </apex:form>

  
</apex:page>





-------------------------------------------------------------------
public class clsAccountControl 
{

 public List<Account> acclist {set;get;}
 
 public clsAccountControl()
 {
     acclist=[Select Name,BillingCity,Custom_Emaail__c ,OwnerId from Account LIMIT 10 OFFSET 10];
 }
 
 
 
  
}

 
So far I have tried this as a workflow and a process builder without luck. I am trying to work out a lfow but this is what I am trying to do:

I have a recruitng app that I built contining 3 objects, applicant, candidiate and empoyee. I am trying to find a way where I can use a selected picklist value in each to change the record type and the object that the record is located in. For example: an applicants gets moved from the applicant object and record type when the picklist value "scheduled interview" is selected. It would be a similar setup to move from candidate to employee.
I have a visualforce page that talks to an Apex class.  I would like to log errors in a separate file that will allow me to check at anytime the errors we have encountered.  How would I implement this in Salesforce?
Hello All,

I set up a workflow to be triggered when the picklist value of Lead Status is "B2C subscriber", when it is created and every time it is edited to subsequently meet this criteria. With the action to update the custom currency field, "Potential B2C Revenue" to 0.00. However, I have tested this and nothing changes when I save a record to the B2C Subscriber status.

It only allows me to select the new Potential Revenue Value as a blank value or a formula. I wasn't aware there was a formula for "0.00"??
Any help would be appreciated. 

 Currency Output Options



Thank you,
Julia
if(mapplcr!=null && !mapplcr.isempty()){
                    system.debug('Line187'+mapplcr);
                    system.debug('Line188'+((oplt.M_PM_Product__c).Product_Leader__c));
                    system.debug('Line189'+contmap);
                    if( mapplcr.get(oplt.M_PM_Product__c).Product_Leader__c!=null)

Please suggest how can I put the debug log , I need to see the value of (oplt.M_PM_Product__c).Product_Leader__c as I am getting null point exception, suggestion please
We have a field "Renewal Date" which would read as say, 1/1/2016. I want to create a formula field that pulls the month out of that - preferably as the name of the month, so in the example "Jan" or "January". 
Can anyone suggest how to approach writing a test class for this extension controller?

I have two custom objects, Proposal and Project where Proposal is a lookup from Project. PopulateProject method shown below is called from a VF page that overrides the New Project button so that whenever a Proposal__c related lookup has been selected it pulls a few fields from the selected Proposal__c record and populates them onto matching fields on the Project_c screen prior to the Project__c object being saved.

I've tried following the tutorials on writing test classes but can't find one that is close to my use case so I don't think I'm heading in the right direction. Any suggestions greatly appreciated. Or just a pointer to a similar example. Thanks in advance!     

public with sharing class RelatedController1
{
public Proposal__c prop {get;set;}

private ApexPages.StandardController stdCtrl;
  
 public RelatedController1(ApexPages.StandardController std)
 {
  stdCtrl=std;
 }
  
 public void PopulateProject()
 {
  Project__c proj=(Project__c) stdCtrl.getRecord();
if(proj.Proposal__c == null){return;}
else{
  prop=[select Name,  Account__c, Scope_of_Work__c, Contact__c from Proposal__c where Id=:proj.Proposal__c];
 
  proj.Name=prop.Name;
  proj.Account__c=prop.Account__c;
  proj.Scope_of_Work__c=prop.Scope_of_Work__c;
  proj.Project_Contact__c=prop.Contact__c;}
 }
}
How to "Recall' a record from approval process? I am using setAction('Removed') but it gives me INSUFFICIENT PRIVILEGES error. Interestingly, it works fine if I Approve or Reject. Salesforce says only system administrators can set it to Removed but my logic is running in System Mode.
 

Hi,
I have a scenario where I have to send an email on case creation. In the email template I am referring the field case owner. Also, in After Insert I am changing the owner of the case by running the assignment rules through code. But the issue is the emails I received show the old owner of the record and not the changed one.
Kindly reply asap.


As I look at the Workflow limits it shows for the per organization limit for a single object - Total workflow rules per object equals 500.  The next row shows that the Total active workflow rules per object equals 50.  Does active mean activated or does it mean running at the same time?  At times I inactivate workflow for troubleshooting purposes, but I always activate them when I finished.  Does it make sense to anyone else that I could have 450 workflow for a single object that are not activated?  What am I missing?
Hi,

I want to change the size of the text-box field and drop-down list field for a flow. I changed the text size on the flow builder so I am wondering if the text-box field size can also be changed there. I tried changing the size of the values in the drop-down list but that did not work.

I have this flow on a visual force page so the CSS tags, if those even exisit, would work too.

Thanks,
-Julio Hernandez
Our developers have created a visualforce webpage, however, it is behind our single sign-on implementation for our Salesforce production environment. We want this visualforce page to be behind one of our community single sign-ons instead. This is because the SAML attributes passed in our community single sign-ons are different from our production environment of Salesforce and the users that need to access this visualforce page are community license users. What needs to happen in order to make this possible?
We have a process builder (on Case object) in a flow of sending reminder emails as in below functional flow.
Criteria met > Update a field on Case(scheduled action) > Case trigger checks for field update and send reminder email.

Recipient will be an person account which is a grand parent object to Case. The personEmail of the person account is being captured, composed the email and send in the trigger.

My question is does Salesforce keep a runtime reference of entire scheduled action flow(up-to trigger and sending email) until it get fired? Or should Salesforce execute the trigger at the real execution time of the scheduled action?

Reason why asking is we observed that even if we change the person account lookup before scheduled action time met, trigger still sends the reminder email to the previous person account personEmail. This sounds like Salesforce keep a runtime reference of entire process of scheduled action.

Appreciate any comments/ confirmation on this.
Hi,
As per my requiremnet I will have to integrate a Userform (Excel or ***) to Salesforce. Once rquester submits the form it should generate a ticket no. and proceed to workflow. Can anyone have any idea to proceed with the same.
So here's the thing. I have a client that wants to provide a login form that is shown on the right hand side of pages where Partners can log in. This will not authenticate them on the current site (like an SSO solution) but instead send their credentials over to salesforce and log them in... taking them to the homepage on the salesforce portal

Hi All,

I was hoping to create an automated email alert to any owner of a lead or account letting them know that the account has been re-assigned. I'm pretty stumped - does anyone have any advice or solutions?

Thanks!

Riley

I currently have a workflow setup to, on opportunity creation, set the opportunity name via Workflow to update field name to YYYY-MM-DDXX, where 'XX' is the number of opp that has been created on that date within the entire org.

For example:
- If I made an opp right now, and it was the first opp created today, it would be named 2017-08-2201
- If I created another opp right after, the opp name would be 2017-08-2202
- ...and so on
- But, when the clock strikes midnight, the last two numbers would reset, so the first opp created after midnight would be 2017-08-2301

The way I have this workflow setup is through an autonumber field, as such: {YYYY}-{MM}-{DD}{00}. The problem I've run into is that the {00} (in the XX in my first example) does not reset daily so, I have to manually change it to a text field, then back to an autonumber field every morning.

I have never written APEX but, I’ve been trying to give it a shot. From what I understand, I have to have a ‘count field’ on the opportunity to keep track of the number made that day. Is this correct?

 
Either way, below is the code I have thus far --
 
 
OppCount = the field I created for the above purpose.
 
 
public class incrementHandler
{
    public void onInsert( list<Opportunity> newList){
 
    List<Opportunity> lstOpp = [SELECT Id,OppCount FROM Opportunity Order BY Createddate DESC LIMIT 1];
    Integer intCounter = lstOpp.size() != 0 ? lstOpp[0].OppCount : 0;
    for(Opportunity objOpportunity: newList)
    {
        intCounter ++;
        objOpportunity.OppCount = intCounter;
    }
 
    }
}
 
 
Any help is much appreciated!
 
Best!
 
Hi all,

I seem to be having a problem with <apex:form>. When I run my visualforce page without out it, my page has no problem loading. However, when I add that tag, it get the view state limit reached error message. Even just putting <apex:form></apex:form> with nothing in between causes the error. Here is my code. 
<apex:page controller="VisitReportPrototypeController">
  <apex:pageBlock>
    <apex:form>
      <apex:outputText value="Select a term: "/>
      <apex:selectList value="{!selectedTermNumber}" multiselect="false" size="1">
        <apex:selectOptions value="{!termOptions}"/>
      </apex:selectList>
    </apex:form>
    <apex:pageBlockTable value="{!group1Rows}" var="row">
      <apex:column value="{!group1[row]}" headerValue="Totals" style="width:150px"/>
      <apex:column value="{!total[row]}" style="width:150px"/>
      <apex:column value="{!totalsFirstYear[row]}" style="width:150px"/>
      <apex:column value="{!totalsTransfer[row]}" style="width:150px"/>
    </apex:pageBlockTable>
    <br />
    <apex:pageBlockTable value="{!group1Rows}" var="row">
      <apex:column value="{!group1[row]}" headerValue="Visited" style="width:150px"/>
      <apex:column value="{!visited[row]}" style="width:150px"/>
      <apex:column value="{!visitedFirstYear[row]}" style="width:150px"/>
      <apex:column value="{!visitedTransfer[row]}" style="width:150px"/>
    </apex:pageBlockTable>
    <br />
    <apex:pageBlockTable value="{!group1Rows}" var="row">
      <apex:column value="{!group1[row]}" headerValue="Not Visited" style="width:150px"/>
      <apex:column value="{!didNotVisit[row]}" style="width:150px"/>
      <apex:column value="{!notVisitedFirstYear[row]}" style="width:150px"/>
      <apex:column value="{!notVisitedTransfer[row]}" style="width:150px"/>
    </apex:pageBlockTable>
    <br />
    <apex:pageBlockTable value="{!group2Rows}" var="row">
      <apex:column value="{!group2[row]}" headerValue="Summary" style="width:150px"/>
      <apex:column value="{!summaryVisited[row]}" style="width:150px"/>
      <apex:column value="{!outOf[row]}" style="width:150px"/>
      <apex:column value="{!percentage[row]}" style="width:150px"/>
    </apex:pageBlockTable>
  </apex:pageBlock>
</apex:page>
User-added image
Also, you can see that the viewstate size is way under the limit. Could anyone tell me why I might be getting this error?
Thanks.
I'd like to create a flow that our HR department can use for onboarding a new hire that creates a user account and configures settings such as assigning a managed package, setting a role, setting a profile, etc.

I haven't found a lot of information on this... is it even possible?
Hey Folks, I have a validation rule on a field for NOT( ISCHANGED) ). I have a button that is triggering this rule when pressed even though the field has been changed. I can't figure out a way around it. Any ideas? This is the button:

{!REQUIRESCRIPT("/soap/ajax/39.0/connection.js")} 

try { 
var newRecords = []; 
var c = new sforce.SObject("Request_for_Information_RFI__c"); 
c.id ="{!Request_for_Information_RFI__c.Id}"; 
c.Submit_RFI__c= true; 
c.Approval_Submitted__c= true; 
newRecords.push(c); 
result = sforce.connection.update(newRecords); 

if( result[0].getBoolean( "success" ) ) { 
window.location.reload(); 

else { 
alert( "An error has occurred. Error:" + result ); 


catch( e ) { 
alert( "An unexpected error has occurred. Error:" + e ); 
}

Hi guys! I've written my first trigger, which works in my sandbox, but I can't successfully write a test for it.  The field that it filters on is a read only formula field.  Any help would be greatly appreciated!
Thanks much!

trigger accountRankings on Account(after insert, after update, after delete){

for(Account acc : trigger.new)
{
//checking if the value is changed
if(acc.VAROrderPointsYTD__c != Null && (trigger.isInsert || (trigger.newMap.get(acc.id).VAROrderPointsYTD__c != trigger.oldMap.get(acc.id).VAROrderPointsYTD__c)))
{
break;
}
else return;
}

//rank top 100 accounts for more accounts change the row limit
List<Account> accounts = [Select VAROrderPointsYTD__c, Point_Ranking__c from Account Where RecordType.Name = 'Richmond VAR' ORDER BY VAROrderPointsYTD__c DESC limit 100];

Integer rank = 1;
for (Account account : accounts)
{
account.Point_Ranking__c = rank;
rank++;
}
update accounts;
}
 

 

I am trying to trigger a field update here's the code I have so far.  Won_Nov_Outings__C is a currency data field.  I can save the trigger, but when i update an opportunity i get this error:
Error: Invalid Data. 
Review all error messages below to correct your data.
Apex trigger testsum2 caused an unexpected exception, contact your administrator: testsum2: execution of AfterUpdate caused by: System.SObjectException: Invalid field sum for AggregateResult: Trigger.testsum2: line 7, column 1

Here is my code:
 
trigger testsum on Opportunity (after update) {
    AggregateResult[] groupedResults = [
    Select SUM (Amount) from Opportunity WHERE Opportunity_Type__c = 'Outing' and Event_Year__C = '2017' AND Event_Month__c = '11_November' AND Probability < 90];
        for (Opportunity obj : Trigger.new)
        {
        double sum =
double.valueOf(groupedResults[0].get('sum'));
        obj.Won_Nov_Outings__c =
decimal.valueOf(sum);
            }
    }

 
I created a Listview that shows Country and State/Providence as fields on the view. When I go to do a MassEdit it gives this error:


core.apexpages.exceptions.ApexPagesHandledException: Object type not accessible. Please check permissions and make sure the object is not in development mode: (IsConverted = FALSE)) ) ORDER BY CountryCode ASC LIMIT 10000 ^ ERROR at Row:2:Column:39 No such column 'CountryCode' on entity 'Lead'. If you are attempting to use a custom field, be sure to append the '__c' after the custom field name. Please reference your WSDL or the describe call for the appropriate names.. Original queryString was: 'SELECT Id, City, Street, State, PostalCode, Country, Company, Corporate_Name__c, Description, Email, Franchise__c, Industry, International_Contact__c, Is_your_company_a_Franchise__c, Name, Salutation, FirstName, LastName, Number_of_Units__c, NumberOfEmployees, Phone, Status, Verticial__c, Website FROM Lead WHERE ( ((OwnerId = '005E0000007aJhC') and (IsConverted = FALSE)) ) ORDER BY CountryCode ASC LIMIT 10000' 

The problem seems to rest with the fact that I have Country and State/Providence in the listview. There is a text only version of each of those fields and when I use those instead I am able to do a mass edit. So I am guessing the problem is with those specific type of fields. I have State and Country/Territory Picklists enabled. If I can use the text only version it's not really an issue, but I would like to know why that version of the field is not working but the other one is. (In case an issue related to this pops up later and there is a resolve for it).

Thanks,

Esther
help me to write trigger if date is less than or equal to 10 , i need to upate previous month last date . if it is above 10 we need to update same day

ex: date : 04-Jun-17   output -- 31-may-17
ex: date  : 10-jun-17  output -- 31-may-17
ex: date   11-jun-17    output -- 11-jun-17
Hello everyone,
We have a Visualforce page calling an Apex Class which currently obtains the record Id from the URL.  We're attempting to implement Console and this process no longer works in Console View.  I'm trying to understand how to replace the referheader with the getEnclosingPrimaryTabObjectId() function for Console, but I keep coming up short.  Any advice would be appreciated!  Here's the existing code:
public with sharing class TaskSidebarExtension {
  public Task tsk {get;set;}
  public String refer {get;set;}
  public Boolean valid {get;set;}
  public String parentId {get;set;}
  public String recordName {get;set;}
  public String phoneNumber {get;set;}
  public string redirectUrl {get;set;}
  
  public TaskSidebarExtension(ApexPages.standardController ctl) {
    this.tsk = (Task)ctl.getRecord();
    
  }
  
  public void findRecord() {
    valid = true;
    try {      
      //check the referer header (send via the iFrame) and extract the record id
      String referHeader = ApexPages.currentPage().getHeaders().get('referer');
      if (referHeader != null) {
        refer = referHeader;
      }
      
      if (refer != null) {
        Integer startPos = refer.lastIndexOf('/')+1;
        Integer endPos = refer.indexOf('?');
        if (endPos < 0) endPos = refer.length();
        
        parentId = refer.substring(startPos,endPos);
      }
      
    
Hi guys I have a following problem:
I added a new button on Account type that OnClick executes JavaScript Function called "makeSensitive()"
On Visualforce Page with standard Account controller I used Account details with this button and also added an ActionFunction with name "makeSensitive".
The problem is that on my Dev / Staging / UAT ORGs everything works fine but in production on clicking this button users get alert with message that "makeSensitive" function is not defined.
What can be the reason?
I am looking for a simple solution to track when a custom url field is clicked on a record. I have a custom object with several URL's (URL Fields with default values) that link to Documents that also reside in Salesforce. I would like to track when a user clicks the link and reads the document. Any suggestions?