• Jay Pollack
  • NEWBIE
  • 0 Points
  • Member since 2010

  • Chatter
    Feed
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 4
    Questions
  • 4
    Replies

I have a User lookup field - but I only want users to be able to select internal users - not portal users.  Anyone know how to hide the drop down in front of the lookup search field?

 



I have a trigger that runs on the User object that updates many Cases in bulk depending on if the User exists in one of several fields on the Case. I run into issues when trying to run this on multiple User records at once, if the # of Cases exceeds 10,000 (due to SF governor limits). I'd like to break this out and use batch Apex - but I'm not sure how I convert this trigger into Batch Apex.

 

Here is the trigger code. I just need some help getting started on breaking this out into Batch. thanks!

 

trigger UpdatePTOonCase on User (after update) {

// this trigger updates the NSR PTO fields on Enterprise Cases based on changes to the NSR flag on the User record.

Set userIds = new Set();

List users = Trigger.new;

 

//list to hold cases that will need to be updated

 List casesToUpdate = new List();

 

 //gather all user ids in the update in a set

for (User u : users) {

userids.add(u.id); }

 

 // grab all open cases where this users is one of the related nsr's and place in map

Map cMap = new Map([SELECT id, nsr_lookup__c, BI_nsr_lookup__c, Tech_nsr_lookup__c, Time_nsr_lookup__c, Talent_nsr_lookup__c FROM Case WHERE isClosed = false AND (nsr_lookup__c in: userids OR BI_NSR_Lookup__c in: userids OR Tech_nsr_lookup__c in: userids OR Talent_nsr_lookup__c in: userids OR Time_nsr_lookup__c in: userids)]);

 

//create list of cases List cases

List = cmap.values();

 

//create set of case id's

Set caseids = cMap.keyset();

 

for (User u : users) {

User old = trigger.oldMap.get(u.id);

 

 if (old.PTO__c != u.PTO__c) {

 

 //loop through Case list and add case id's

for (Case c :casesList) {

 

 if (c.nsr_lookup__c == u.id) {

//set NSR PTO Field on Case

c.nsr_pto__c = u.PTO__c; }

 

 if (c.BI_nsr_lookup__c == u.id) {

//set NSR PTO Field on Case

c.BI_nsr_pto__c = u.PTO__c; }

 

if (c.Tech_nsr_lookup__c == u.id) {

//set NSR PTO Field on Case

 c.Tech_nsr_pto__c = u.PTO__c; }

 

 if (c.Time_nsr_lookup__c == u.id) {

 //set NSR PTO Field on Case

c.Time_nsr_pto__c = u.PTO__c; }

 

 if (c.Talent_nsr_lookup__c == u.id) {

 //set NSR PTO Field on Case

c.Talent_nsr_pto__c = u.PTO__c; }

 

casesToUpdate.add(c); } } }

 

//call method to prevent case triggers from firing

 PreventRecursive.setUpdatedFromUser ();

 

update casesToUpdate ; }

I am trying to render a picklist when a certain value is selected on a previous picklist.  Right now picklist #2 does not render, when I change the value on picklist 1 I see the screen flash, but #2 does not render.  Any suggestions are appreciated.

 

Controller:

public with sharing class WPCaseAction {

public Case_Action__c ca; //Case Action sobject
public Boolean actionIsCloseCase { get; set;}

//initializes the private member variable by using the getRecord method from the standard controller
public WPCaseAction (ApexPages.StandardController stdController)
{
this.ca = (Case_Action__c )stdController.getRecord();

if (ca.case__c!= null)
{
Case c = [select Current_Stage__c, Status, Next_Step__c from Case where id =: ca.case__c limit 1];
ca.Stage__c = c.Current_Stage__c;
ca.Case_Status__c = c.Status;
ca.Next_Step__c = c.Next_Step__c;
}

}


public List<SelectOption> getAct() {

List<SelectOption> options = new List<SelectOption>();

if (ca.Case_Status__c == 'Closed')
{
options.add(new SelectOption('Re-Open Case','Re-Open Case'));
}

if (ca.Stage__c == '0 - Define Specifications' && ca.Case_Status__c != 'Closed')
{
options.add(new selectOption('', '- Please Select an Action -'));
options.add(new SelectOption('Submit Request to Integration Team','Submit Request to Integration Team'));
options.add(new SelectOption('Close Case','Close Case'));
options.add(new SelectOption('Place Request on Hold','Place Request on Hold'));
}


else if (ca.Stage__c == '1 - Review Specifications' && ca.Case_Status__c != 'Closed')
{
options.add(new selectOption('', '- Please Select an Action -'));
options.add(new selectOption('Request Information - Return to Case Creator', 'Request Information - Return to Case Creator'));
options.add(new selectOption('Provide Information - Return to IC', 'Provide Information - Return to IC'));
options.add(new selectOption('Assign Request to Create Export - to IC', 'Assign Request to Create Export - to IC'));
options.add(new selectOption('Submit Request to Technical Team', 'Submit Request to Technical Team'));
options.add(new SelectOption('Close Case','Close Case'));
options.add(new SelectOption('Place Request on Hold','Place Request on Hold'));
}

else if (ca.Stage__c == '2 - Create Export' && ca.Case_Status__c != 'Closed')
{
options.add(new selectOption('', '- Please Select an Action -'));
options.add(new selectOption('Assign Request to Create Export - to TC', 'Assign Request to Create Export - to TC'));
options.add(new selectOption('Request Information - Return to IC', 'Request Information - Return to IC'));
options.add(new selectOption('Request Information - Return to Case Creator', 'Request Information - Return to Case Creator'));
options.add(new selectOption('Provide Information - Return to TC', 'Provide Information - Return to TC'));
options.add(new selectOption('Provide Information - Return to IC', 'Provide Information - Return to IC'));
options.add(new selectOption('Submit Export for Testing', 'Submit Export for Testing'));
options.add(new SelectOption('Close Case','Close Case'));
options.add(new SelectOption('Place Request on Hold','Place Request on Hold'));
}

else if (ca.Stage__c == '3 - Testing' && ca.Case_Status__c != 'Closed')
{
options.add(new selectOption('', '- Please Select an Action -'));
options.add(new selectOption('Submit Export for Testing', 'Submit Export for Testing'));
options.add(new selectOption('Testing - Waiting on Customer', 'Testing - Waiting on Customer'));
options.add(new selectOption('Testing - Waiting on Case Creator', 'Testing - Waiting on Case Creator'));
options.add(new selectOption('Testing - Waiting on TC', 'Testing - Waiting on TC'));
options.add(new selectOption('Testing - Waiting on Vendor', 'Testing - Waiting on Vendor'));
options.add(new selectOption('Approve Export for Scheduling', 'Approve Export for Scheduling'));
options.add(new SelectOption('Close Case','Close Case'));
options.add(new SelectOption('Place Request on Hold','Place Request on Hold'));
}

else if (ca.Stage__c == '4 - Schedule Export' && ca.Case_Status__c != 'Closed')
{
options.add(new selectOption('', '- Please Select an Action -'));
options.add(new SelectOption('Close Case','Close Case'));
options.add(new SelectOption('Place Request on Hold','Place Request on Hold'));
}

return options;
}


public List<SelectOption> getReasonCode()
{

List<SelectOption> options = new List<SelectOption>();

options.add(new selectOption('', 'Client Changing Vendors'));
options.add(new selectOption('', 'Client Decided Against Electronic Feeds'));
options.add(new selectOption('', 'Client Resources Unable to Commit'));
options.add(new selectOption('', 'Other – Miscellaneous'));
options.add(new selectOption('', 'Request Made in Error'));
options.add(new selectOption('', 'Vendor Cannot Accept Electronic Feeds from US'));


return options;
}

public pagereference reloadReasonsPicklistRender()
{
 if(action == 'Close Case')
actionIsCloseCase = true;
else actionIsCloseCase = false;

return null;
}

}

 

Visual Force Page:

<apex:page standardController="Case_Action__c" extensions="WPCaseAction" >
<apex:form >

<apex:actionFunction name="jsReloadReasonsPicklistRender" action="{!reloadReasonsPicklistRender}" rerender="ReasonPanel" status="myStatus" />


<apex:pageBlock title="Action" mode="mainDetail" ID="CaseAction">
<apex:pageblockButtons >
<apex:commandButton action="{!Save}" Value="Save" />
<apex:commandButton action="{!Cancel}" Value="Cancel" />
</apex:pageblockButtons>

<apex:pageBlockSection columns="1">
<apex:pageMessages >
</apex:pagemessages>
</apex:pageBlockSection>


<apex:pageBlockSection title="Case Information" columns="1">
<apex:outputfield value="{!Case_Action__c.Case__c}"/>
<apex:outputfield value="{!Case_Action__c.Case_Status__c}"/>
<apex:pageBlockSectionItem >
<apex:outputLabel value="Current Stage" ></apex:outputLabel>
<apex:outputText > {!Case_Action__c.Stage__c} </apex:outputText>
</apex:pageBlockSectionItem>


<apex:pageBlockSectionItem >
<apex:outputLabel value="Next Step" ></apex:outputLabel>
<apex:outputText > {!Case_Action__c.Next_Step__c} </apex:outputText>
</apex:pageBlockSectionItem>

</apex:pageBlockSection>

<apex:pageBlockSection Title="Action" columns="1">
<apex:pageBlockSectionItem >
<apex:outputLabel value="Action" ></apex:outputLabel>
<apex:selectList id="act" value="{!Case_Action__c.Action__c}" size="1" Title="Action" onchange="jsReloadReasonsPicklistRender();" >
<apex:selectOptions value="{!act}">
</apex:selectOptions>
</apex:selectList>
</apex:pageBlockSectionItem>
</apex:pageBlockSection>

<apex:actionStatus startText="Refreshing..." id="myStatus"/>

<apex:outputpanel id="ReasonPanel" rendered="actionIsCloseCase">
<apex:pageBlockSection columns="1" >

<apex:pageBlockSectionItem >

<apex:outputLabel value="Reason" ></apex:outputLabel>
<apex:selectList value="{!Case_Action__c.Reason_Code__c}" size="1" >
<apex:selectOptions value="{!ReasonCode}">
</apex:selectOptions>
</apex:selectList>

</apex:pageBlockSectionItem>
</apex:pageBlockSection>
</apex:outputpanel >

<apex:pageBlockSection columns="1">

<apex:inputField value="{!Case_Action__c.Requested_By_Date__c}" required="true"/>
<apex:inputField value="{!Case_Action__c.Follow_Up_Date__c}" required="true"/>

</apex:pageBlockSection>

<apex:pageBlockSection columns="1" >

</apex:pageBlockSection>
<apex:pageBlockSection columns="1">
<apex:outputtext />
<apex:inputfield value="{!Case_Action__c.Comments__c}" required="true" style="width:75%;"/>
</apex:pageBlockSection>


</apex:pageBlock>

<apex:actionStatus startstyle="color:green;" startText="Updating page ..." id="StatusChange"/>

<script>function setFocusOnLoad() {}</script>

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


I've created a custom button to allow users to create a case from the Contact related list on the Account tab.  It works great when a user scrolls down and uses the related list.  But if you use the related list hover at the top, the new case opens up in the hover itself and them promptly disappears when you move away.

 

I'm looking for a way to have this work whether you are in the hover or not without having the button open in a new window.  If there any way to tell my button if it's opening up from the hover or from the bottom related list?

 

This is the button code:

 

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

var records = {!GETRECORDIDS($ObjectType.Contact)}; //grabs the Contact records displayed on the search page.

var updateRecords = []; //array for holding records that this code will ultimately update

if (records[0] == null)
{ //if the button was clicked but there was no record selected
alert("Please select at least one Contact."); //alert the user that they didn't make a selection
}

else
{
//otherwise, there was a record selection

for (var a=0; a<=0; a++) { //for all records
var objContact = new sforce.SObject("Contact"); //create a new sObject for storing updated record details
objContact = records[a]; //set the Id of the selected Contact record
updateRecords.push(objContact); //add the updated record to our array

}

window.location.href= "/500/e?&def_contact_id="+updateRecords;

//window.open( "/500/e?&def_contact_id="+updateRecords,'name');


}

 

Thanks in advance for any help!

I have a User lookup field - but I only want users to be able to select internal users - not portal users.  Anyone know how to hide the drop down in front of the lookup search field?

 



I am trying to render a picklist when a certain value is selected on a previous picklist.  Right now picklist #2 does not render, when I change the value on picklist 1 I see the screen flash, but #2 does not render.  Any suggestions are appreciated.

 

Controller:

public with sharing class WPCaseAction {

public Case_Action__c ca; //Case Action sobject
public Boolean actionIsCloseCase { get; set;}

//initializes the private member variable by using the getRecord method from the standard controller
public WPCaseAction (ApexPages.StandardController stdController)
{
this.ca = (Case_Action__c )stdController.getRecord();

if (ca.case__c!= null)
{
Case c = [select Current_Stage__c, Status, Next_Step__c from Case where id =: ca.case__c limit 1];
ca.Stage__c = c.Current_Stage__c;
ca.Case_Status__c = c.Status;
ca.Next_Step__c = c.Next_Step__c;
}

}


public List<SelectOption> getAct() {

List<SelectOption> options = new List<SelectOption>();

if (ca.Case_Status__c == 'Closed')
{
options.add(new SelectOption('Re-Open Case','Re-Open Case'));
}

if (ca.Stage__c == '0 - Define Specifications' && ca.Case_Status__c != 'Closed')
{
options.add(new selectOption('', '- Please Select an Action -'));
options.add(new SelectOption('Submit Request to Integration Team','Submit Request to Integration Team'));
options.add(new SelectOption('Close Case','Close Case'));
options.add(new SelectOption('Place Request on Hold','Place Request on Hold'));
}


else if (ca.Stage__c == '1 - Review Specifications' && ca.Case_Status__c != 'Closed')
{
options.add(new selectOption('', '- Please Select an Action -'));
options.add(new selectOption('Request Information - Return to Case Creator', 'Request Information - Return to Case Creator'));
options.add(new selectOption('Provide Information - Return to IC', 'Provide Information - Return to IC'));
options.add(new selectOption('Assign Request to Create Export - to IC', 'Assign Request to Create Export - to IC'));
options.add(new selectOption('Submit Request to Technical Team', 'Submit Request to Technical Team'));
options.add(new SelectOption('Close Case','Close Case'));
options.add(new SelectOption('Place Request on Hold','Place Request on Hold'));
}

else if (ca.Stage__c == '2 - Create Export' && ca.Case_Status__c != 'Closed')
{
options.add(new selectOption('', '- Please Select an Action -'));
options.add(new selectOption('Assign Request to Create Export - to TC', 'Assign Request to Create Export - to TC'));
options.add(new selectOption('Request Information - Return to IC', 'Request Information - Return to IC'));
options.add(new selectOption('Request Information - Return to Case Creator', 'Request Information - Return to Case Creator'));
options.add(new selectOption('Provide Information - Return to TC', 'Provide Information - Return to TC'));
options.add(new selectOption('Provide Information - Return to IC', 'Provide Information - Return to IC'));
options.add(new selectOption('Submit Export for Testing', 'Submit Export for Testing'));
options.add(new SelectOption('Close Case','Close Case'));
options.add(new SelectOption('Place Request on Hold','Place Request on Hold'));
}

else if (ca.Stage__c == '3 - Testing' && ca.Case_Status__c != 'Closed')
{
options.add(new selectOption('', '- Please Select an Action -'));
options.add(new selectOption('Submit Export for Testing', 'Submit Export for Testing'));
options.add(new selectOption('Testing - Waiting on Customer', 'Testing - Waiting on Customer'));
options.add(new selectOption('Testing - Waiting on Case Creator', 'Testing - Waiting on Case Creator'));
options.add(new selectOption('Testing - Waiting on TC', 'Testing - Waiting on TC'));
options.add(new selectOption('Testing - Waiting on Vendor', 'Testing - Waiting on Vendor'));
options.add(new selectOption('Approve Export for Scheduling', 'Approve Export for Scheduling'));
options.add(new SelectOption('Close Case','Close Case'));
options.add(new SelectOption('Place Request on Hold','Place Request on Hold'));
}

else if (ca.Stage__c == '4 - Schedule Export' && ca.Case_Status__c != 'Closed')
{
options.add(new selectOption('', '- Please Select an Action -'));
options.add(new SelectOption('Close Case','Close Case'));
options.add(new SelectOption('Place Request on Hold','Place Request on Hold'));
}

return options;
}


public List<SelectOption> getReasonCode()
{

List<SelectOption> options = new List<SelectOption>();

options.add(new selectOption('', 'Client Changing Vendors'));
options.add(new selectOption('', 'Client Decided Against Electronic Feeds'));
options.add(new selectOption('', 'Client Resources Unable to Commit'));
options.add(new selectOption('', 'Other – Miscellaneous'));
options.add(new selectOption('', 'Request Made in Error'));
options.add(new selectOption('', 'Vendor Cannot Accept Electronic Feeds from US'));


return options;
}

public pagereference reloadReasonsPicklistRender()
{
 if(action == 'Close Case')
actionIsCloseCase = true;
else actionIsCloseCase = false;

return null;
}

}

 

Visual Force Page:

<apex:page standardController="Case_Action__c" extensions="WPCaseAction" >
<apex:form >

<apex:actionFunction name="jsReloadReasonsPicklistRender" action="{!reloadReasonsPicklistRender}" rerender="ReasonPanel" status="myStatus" />


<apex:pageBlock title="Action" mode="mainDetail" ID="CaseAction">
<apex:pageblockButtons >
<apex:commandButton action="{!Save}" Value="Save" />
<apex:commandButton action="{!Cancel}" Value="Cancel" />
</apex:pageblockButtons>

<apex:pageBlockSection columns="1">
<apex:pageMessages >
</apex:pagemessages>
</apex:pageBlockSection>


<apex:pageBlockSection title="Case Information" columns="1">
<apex:outputfield value="{!Case_Action__c.Case__c}"/>
<apex:outputfield value="{!Case_Action__c.Case_Status__c}"/>
<apex:pageBlockSectionItem >
<apex:outputLabel value="Current Stage" ></apex:outputLabel>
<apex:outputText > {!Case_Action__c.Stage__c} </apex:outputText>
</apex:pageBlockSectionItem>


<apex:pageBlockSectionItem >
<apex:outputLabel value="Next Step" ></apex:outputLabel>
<apex:outputText > {!Case_Action__c.Next_Step__c} </apex:outputText>
</apex:pageBlockSectionItem>

</apex:pageBlockSection>

<apex:pageBlockSection Title="Action" columns="1">
<apex:pageBlockSectionItem >
<apex:outputLabel value="Action" ></apex:outputLabel>
<apex:selectList id="act" value="{!Case_Action__c.Action__c}" size="1" Title="Action" onchange="jsReloadReasonsPicklistRender();" >
<apex:selectOptions value="{!act}">
</apex:selectOptions>
</apex:selectList>
</apex:pageBlockSectionItem>
</apex:pageBlockSection>

<apex:actionStatus startText="Refreshing..." id="myStatus"/>

<apex:outputpanel id="ReasonPanel" rendered="actionIsCloseCase">
<apex:pageBlockSection columns="1" >

<apex:pageBlockSectionItem >

<apex:outputLabel value="Reason" ></apex:outputLabel>
<apex:selectList value="{!Case_Action__c.Reason_Code__c}" size="1" >
<apex:selectOptions value="{!ReasonCode}">
</apex:selectOptions>
</apex:selectList>

</apex:pageBlockSectionItem>
</apex:pageBlockSection>
</apex:outputpanel >

<apex:pageBlockSection columns="1">

<apex:inputField value="{!Case_Action__c.Requested_By_Date__c}" required="true"/>
<apex:inputField value="{!Case_Action__c.Follow_Up_Date__c}" required="true"/>

</apex:pageBlockSection>

<apex:pageBlockSection columns="1" >

</apex:pageBlockSection>
<apex:pageBlockSection columns="1">
<apex:outputtext />
<apex:inputfield value="{!Case_Action__c.Comments__c}" required="true" style="width:75%;"/>
</apex:pageBlockSection>


</apex:pageBlock>

<apex:actionStatus startstyle="color:green;" startText="Updating page ..." id="StatusChange"/>

<script>function setFocusOnLoad() {}</script>

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


I've created a custom button to allow users to create a case from the Contact related list on the Account tab.  It works great when a user scrolls down and uses the related list.  But if you use the related list hover at the top, the new case opens up in the hover itself and them promptly disappears when you move away.

 

I'm looking for a way to have this work whether you are in the hover or not without having the button open in a new window.  If there any way to tell my button if it's opening up from the hover or from the bottom related list?

 

This is the button code:

 

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

var records = {!GETRECORDIDS($ObjectType.Contact)}; //grabs the Contact records displayed on the search page.

var updateRecords = []; //array for holding records that this code will ultimately update

if (records[0] == null)
{ //if the button was clicked but there was no record selected
alert("Please select at least one Contact."); //alert the user that they didn't make a selection
}

else
{
//otherwise, there was a record selection

for (var a=0; a<=0; a++) { //for all records
var objContact = new sforce.SObject("Contact"); //create a new sObject for storing updated record details
objContact = records[a]; //set the Id of the selected Contact record
updateRecords.push(objContact); //add the updated record to our array

}

window.location.href= "/500/e?&def_contact_id="+updateRecords;

//window.open( "/500/e?&def_contact_id="+updateRecords,'name');


}

 

Thanks in advance for any help!