• Lindsay87
  • NEWBIE
  • 10 Points
  • Member since 2016

  • Chatter
    Feed
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 3
    Questions
  • 0
    Replies
Hi All!

We have a trigger to prevent users from deleting events in salesforce:

Trigger PreventDelete on Event (before delete)

{Profile adminId = [SELECT Id from Profile where Name='System Administrator' LIMIT 1];if(System.Trigger.IsDelete && UserInfo.getProfileId() != adminId.Id)
      {
    for(Event tsk : Trigger.old)
    {
      tsk.addError('Meetings can not be deleted.  Please mark as Cancelled or reschedule to a different day/time.');
    }
 }
 }

But I cannot deploy it because it has 0% code coverage.  I am guessing I need a test class but do not know how to do that.  Can anyone help?  Thanks!
Hi All!  We would like to set up a type of call center scripts for our users when they leave messages with customers.  We are trying to set up a visualforce page but seem to have trouble pulling in the 'First Name' from the Account object.  

Right now, we have it set up as a pop-up - though I cannot figure out how to make the pop-up open in a new window.  Here's the Apex code and Visualforce code as of right now:
 
public with sharing class TestPopup { 
    public String getContact() {
        return null;
    }
    public TestPopup() {
    }
    public TestPopup(Account controller) {
    }
    public TestPopup(ApexPages.StandardController controller) {
    }
    public String account { get; set; }
    public boolean displayPopup {get; set;}     
    public void closePopup() {        
        displayPopup = false;    
    }     
    public void showPopup() {        
        displayPopup = true;    
    }
  }

Visualforce:
<apex:page standardController="Account" extensions="TestPopup">

<apex:form >
<apex:pageBlock >
<apex:commandButton value="Follow Up Day 2" action="{!showPopup}" rerender="popup" status="status"/>
             <apex:outputPanel id="popup">
                <apex:outputPanel id="popInnerOutputPnl" styleClass="customPopup" layout="block" rendered="{!displayPopUp}">
                     <apex:commandButton value="X" title="Close the popup" action="{!closePopup}" styleClass="closeButton" rerender="popup">
                     </apex:commandButton>
                     <apex:pageblockSection >                         
                         
                         <apex:pageblockSectionItem >
                          Hello this is {!$User.FirstName} {!$User.LastName} with ___ and this message is for FIRSTNAME.  
                          I wanted to reach out to you because I just had a customer that came back in and met with the CAD team to design and price out their home.  
                          They were amazed that they were able to sit down and actually have us draw their home and the changes they wanted.  
                          They said it really helped them envision how their new home was going to look and feel.
                          So, I would like to extend that same opportunity to you.  We can set up a time for you to meet and can get things started for you.  
                          I think this would be a really good next step for you and I would be happy to get this scheduled.
                          You can reach me at {!$User.Phone}.  Thank you FirstName have a great rest of the day!
                         </apex:pageblockSectionItem>
                   </apex:pageblocksection>
                </apex:outputPanel>
            </apex:outputPanel>
            </apex:pageBlock>
              </apex:form>
                  <style type="text/css">
.customPopup {
    background-color: white;
    border-style: solid;
    border-width: 2px;
    left: 20%;
    padding: 10px;
    position: absolute;
    z-index: 9999;
    /* These are the 3 css properties you will need to tweak so the pop 
                            up displays in the center of the screen. First set the width. Then set 
                            margin-left to negative half of what the width is. You can also add 
                            the height property for a fixed size pop up.*/
    width: 500px;
    top: 20%;
}

.disabledTextBox {
    background-color: white;
    border: 1px solid;
    color: black;
    cursor: default;
    width: 400px;
    display: table;
    padding: 2px 1px;
    text-align:right;
}   

.closeButton {
    float: right;
}
</style>


</apex:page>

I am not a developer and most of this I did copy and paste from other posts - but could not find anything that would allow me to do a pop up script and pull the information (first name) from the account.  

Can anyone point us in the right direction to pull the first name into this script pop up?

Thanks!
Hello!  New admin here looking for some help.  
 
One of our users has reported that "For some reason on almost every lead I convert, I get the attached duplicate file window even when there is no duplicate. It is also not giving me a link to the duplicate record it's telling me I am creating. " This error message pops up almost every time she converts a lead, even when there is no duplicate record.
Error Message
We have a 'Convert Lead' button that is used and here is the OnClick JavaScript for that:

{!REQUIRESCRIPT("/soap/ajax/20.0/connection.js")} 
{!REQUIRESCRIPT("/soap/ajax/20.0/apex.js")} 
var x=sforce.apex.execute("SH_Household_Utils","ConvertLead", {leadId:"{!Lead.Id}"}); 
var y = ""+x; 
if ( y.length!= 18 || y.substr(0,3)!="001") { 
alert("Error Convert Lead: "+y); 

else { 
var t = confirm("Lead is successfully converted into household and contact. Do you want to create a task for the new household?") ? "/00T/e?what_id="+y+"&retURL=%2F"+y : "/"+y; 
top.location.replace(t); 
}

When she goes to convert the lead, it still does convert it to a household but the pop up shows on almost every lead she converts.  It's just rather inconvenient to have to close the error each time.
What do we need to do in order to prevent this error message from coming up on almost every lead conversion? Especially for ones where there is no duplicate in the system.

We submitted a ticket with Salesforce and they told us to post on here.  Any help would be great.  Thanks!