• Mikhail Nitko 5
  • NEWBIE
  • 25 Points
  • Member since 2017

  • Chatter
    Feed
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 4
    Questions
  • 5
    Replies
Hi folks and thank you for taking a look at this question,

I am getting this error in a trigger in an org I inherited, but the error is not always presenting itself and I cant figure out exactly how to fix it.

All my research shows that it is a governor limit error, but I'm not sure how to fix it in this inherited code. And the code is as follows:
 
trigger ProcessWebFields on Lead (after insert, after update) {

  for (Lead updatedLead : Trigger.new) {  
        
        // If these criteria are met, we've just create a Lead and 
        // there are values in the Web_UMOL field.
        if(updatedLead.Web_Program_of_Interest__c != NULL && updatedLead.Primary_Program_of_Interest__c == NULL){
          
          // Break up the Web_ field
          String[] umolProgramsArr = updatedLead.Web_Program_of_Interest__c.split(';');
          
          // Create Point of Interest records
          for(String program : umolProgramsArr) {
            Utilities.registerInterest(updatedLead.Id, program);
          }

          // Set the main Program of Interest
            List<Program__c> primaryProgramList = [SELECT Id FROM Program__c WHERE Name = :Utilities.getRealProgramName(umolProgramsArr[0])];
            if(primaryProgramList.size() == 1){
                Utilities.setPrimaryProgramOfInterest(updatedLead.Id, umolProgramsArr[0]); 
                Utilities.checkPrimaryPOI(updatedLead.Id, primaryProgramList[0].Id);
            }
            
         
         // Otherwise, we are evaluating a change made that will effect the Primary 
         // Program of Interest lookup field.
        } else {

          // If no Trigger.old, it's the first time running through and we don't want this code.
          if(Trigger.old != null){
            Lead oldLead = Trigger.oldMap.get(updatedLead.Id);
            // Check to see if there is a change to the Primary_Program_of_Interest__c lookup
          if(updatedLead.Primary_Program_of_Interest__c != oldLead.Primary_Program_of_Interest__c){
            Utilities.syncPrimaryPOI(updatedLead.Id, updatedLead.Primary_Program_of_Interest__c);
          }
          }
          
        }

        

    }

Thank you for helping folks.
Hi folks,

I'm trying to create the following PushTopic
 
PushTopic pt = new PushTopic();

pt.Name = 'CaseNotifications';

pt.Query ='SELECT Display_Name__c,Display_Screen_Suffix__c FROM Case WHERE Origin = 'Walk-in' AND Status != 'Closed' AND Remove_From_Screen__c = False ORDER BY CreatedDate ASC NULLS FIRST LIMIT 10';

pt.ApiVersion = 40.0;

pt.NotifyForFields = 'Referenced';

pt.NotifyForOperationCreate = true;

pt.NotifyForOperationUpdate = true;

pt.NotifyForOperationUndelete = true;

pt.NotifyForOperationDelete = true;

insert pt;

And receiving an error that states: "Line: 5, Column: 85 expecting a semi-colon, found 'Walk'"

And I am trying to figure out whats going on, but I know for a fact that the query is formed right, because I use that query in a class and formed it via Workbench.

What is going on?
Hi folks,

I created a case system for my university to work with student cases and I'm having an issue where advisors accept a case simultaneously and the ownership bounces around, while the student and advisors are confused.

To resolve this, I created an accept button that checks whether the owner of the case is a Queue or a User, and to block ownership change if another User owns the case.

But while this works in the vast majority of cases, I can't seem to get it to be perfect, and we still have a few cases per day where the student's case gets bounced around.
Can anyone suggest how I may improve my Accept button code? .. should I have it check ownership twice at the top before proceeding?

Code: 
{!REQUIRESCRIPT("/soap/ajax/28.0/connection.js")} 
var objCase = sforce.connection.query("SELECT Id, OwnerId, Case_Owner_s__c from Case where id ='{!Case.Id}' limit 1"); 
var records = objCase.getArray("records"); 
var caseOwner = records[0].OwnerId; 
var caseOwnerName = records[0].Case_Owner_s__c; 

if(caseOwner.substring(0,3)=='005'){ 
alert("This case has already been accepted by " + caseOwnerName +" and is not in a Queue."); 
} 
else 
{ 
var caseObj = new sforce.SObject("Case"); 
caseObj.Id = '{!Case.Id}'; 
caseObj.OwnerId = '{!$User.Id}'; 
caseObj.One_Stop_Counter__c = "{!TEXT($User.Assigned_Counter__c)}"; 
caseObj.Display_Screen_Suffix__c = "see " + '{!User.FirstName}'+" at Counter "+'{!TEXT($User.Assigned_Counter__c)}'; 
var result = sforce.connection.update([caseObj]); 

if (result[0].success=='false'){ 
alert(result[0].errors.message); 
} 
else { 
window.parent.location.href="/{!Case.Id}"; 
} 
}

Thank you,
Mikhail
Hi folks,

I'm trying to create a sort of "Master Case" window in Visualforce, that shows 3 List Views of the same Cases object.

I'm using the following code to do this.
 
<apex:page>
  <apex:enhancedList type="Case" height="300" rowsPerPage="25" id="Walk_in_Line" customizable="false" />
  <apex:enhancedList type="Case" height="300" rowsPerPage="25" id="Web_Cases" customizable="false" />
  <apex:enhancedList type="Case" height="300" rowsPerPage="50" id="MyOpenCases" customizable="false" />
</apex:page>
And you can see where I'm targetting the same Object, but using a different ID each time, to target different List Views.

The problem is that when the window finaly opens, each of the List Views is set to view the last List View ID that I used.  Meaning that I get a window with 3 List Views, but they're all set to "MyOpenCases".

Is this a bug or am I doing something wrong?

Thank you for any help!
Hi folks and thank you for taking a look at this question,

I am getting this error in a trigger in an org I inherited, but the error is not always presenting itself and I cant figure out exactly how to fix it.

All my research shows that it is a governor limit error, but I'm not sure how to fix it in this inherited code. And the code is as follows:
 
trigger ProcessWebFields on Lead (after insert, after update) {

  for (Lead updatedLead : Trigger.new) {  
        
        // If these criteria are met, we've just create a Lead and 
        // there are values in the Web_UMOL field.
        if(updatedLead.Web_Program_of_Interest__c != NULL && updatedLead.Primary_Program_of_Interest__c == NULL){
          
          // Break up the Web_ field
          String[] umolProgramsArr = updatedLead.Web_Program_of_Interest__c.split(';');
          
          // Create Point of Interest records
          for(String program : umolProgramsArr) {
            Utilities.registerInterest(updatedLead.Id, program);
          }

          // Set the main Program of Interest
            List<Program__c> primaryProgramList = [SELECT Id FROM Program__c WHERE Name = :Utilities.getRealProgramName(umolProgramsArr[0])];
            if(primaryProgramList.size() == 1){
                Utilities.setPrimaryProgramOfInterest(updatedLead.Id, umolProgramsArr[0]); 
                Utilities.checkPrimaryPOI(updatedLead.Id, primaryProgramList[0].Id);
            }
            
         
         // Otherwise, we are evaluating a change made that will effect the Primary 
         // Program of Interest lookup field.
        } else {

          // If no Trigger.old, it's the first time running through and we don't want this code.
          if(Trigger.old != null){
            Lead oldLead = Trigger.oldMap.get(updatedLead.Id);
            // Check to see if there is a change to the Primary_Program_of_Interest__c lookup
          if(updatedLead.Primary_Program_of_Interest__c != oldLead.Primary_Program_of_Interest__c){
            Utilities.syncPrimaryPOI(updatedLead.Id, updatedLead.Primary_Program_of_Interest__c);
          }
          }
          
        }

        

    }

Thank you for helping folks.
Hi folks,

I'm trying to create the following PushTopic
 
PushTopic pt = new PushTopic();

pt.Name = 'CaseNotifications';

pt.Query ='SELECT Display_Name__c,Display_Screen_Suffix__c FROM Case WHERE Origin = 'Walk-in' AND Status != 'Closed' AND Remove_From_Screen__c = False ORDER BY CreatedDate ASC NULLS FIRST LIMIT 10';

pt.ApiVersion = 40.0;

pt.NotifyForFields = 'Referenced';

pt.NotifyForOperationCreate = true;

pt.NotifyForOperationUpdate = true;

pt.NotifyForOperationUndelete = true;

pt.NotifyForOperationDelete = true;

insert pt;

And receiving an error that states: "Line: 5, Column: 85 expecting a semi-colon, found 'Walk'"

And I am trying to figure out whats going on, but I know for a fact that the query is formed right, because I use that query in a class and formed it via Workbench.

What is going on?
Hi folks,

I put a custom button on Salesforce cases that both Accepts a case and checks whether it the case is owned by a User or Queue, and gives an error when one user tries to take the case from another User, and not from a Queue.

The trouble is this button only works if one user opens the case after another has accepted it.  But if both users open an unaccepted case, the button will unfortunately allow the case to first be taken by the first person and then the second, without alerting.

The code:
{!REQUIRESCRIPT("/soap/ajax/13.0/connection.js")}



if('{!Case.OwnerId}'.substring(0,3)=='005'){
alert("This case is owned by " +'{!Case.Case_Owner_s__c}'+" and is not in a Queue.");
} else 

{

var caseObj = new sforce.SObject("Case");
caseObj.Id = '{!Case.Id}';
caseObj.OwnerId = '{!$User.Id}';
caseObj.One_Stop_Counter__c = "{!TEXT($User.Assigned_Counter__c)}";
caseObj.Display_Screen_Suffix__c = "see " + '{!User.FirstName}'+" at Counter  "+'{!TEXT($User.Assigned_Counter__c)}';
var result = sforce.connection.update([caseObj]);

if (result[0].success=='false'){
alert(result[0].errors.message);
} else {
window.parent.location.href="/{!Case.Id}";
}
}

My original solution to this was to have the code in the Accept button refresh the page before running its User owner check, but this does not seem to be working either.

I was adding location.reload(true); before the User check.

Can anyone tell me why the refresh solution isn't working, or if there is another way to either do the refresh, or to execute my intentions?
Hi folks,

I'm trying to create a sort of "Master Case" window in Visualforce, that shows 3 List Views of the same Cases object.

I'm using the following code to do this.
 
<apex:page>
  <apex:enhancedList type="Case" height="300" rowsPerPage="25" id="Walk_in_Line" customizable="false" />
  <apex:enhancedList type="Case" height="300" rowsPerPage="25" id="Web_Cases" customizable="false" />
  <apex:enhancedList type="Case" height="300" rowsPerPage="50" id="MyOpenCases" customizable="false" />
</apex:page>
And you can see where I'm targetting the same Object, but using a different ID each time, to target different List Views.

The problem is that when the window finaly opens, each of the List Views is set to view the last List View ID that I used.  Meaning that I get a window with 3 List Views, but they're all set to "MyOpenCases".

Is this a bug or am I doing something wrong?

Thank you for any help!