• Jason Flippen
  • NEWBIE
  • 90 Points
  • Member since 2016
  • Senior CRM Developer
  • Demand Chain Systems

  • Chatter
    Feed
  • 3
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 0
    Questions
  • 17
    Replies
Hello, I am writing a code where i want to show contact name as a link. so after clicking on the name i will go into org and edit delete the record. I want this on this line.   <apex:column colspan="5" value="{!accWrap.acc.Name}" /> Can anyone help me to achiev this?




<apex:page controller="ContactSelectClassController" sidebar="false" showHeader="false" standardStylesheets="false">
<html>
<head>
<meta charset="utf-8"/>
<meta http-equiv="X-UA-Compatible" content="IE=edge"/>
<meta name="viewport" content="width=device-width, initial-scale=1"/>
<title>Send Mail</title>
<apex:stylesheet value="https://fonts.googleapis.com/css?family=Roboto:400,300,500,700,900"/>
<apex:stylesheet value="{!$Resource.SurveyMaster}"/>
<apex:includeScript value="https://ajax.googleapis.com/ajax/libs/jquery/1.12.2/jquery.min.js"/ >
<!--<link href="https://fonts.googleapis.com/css?family=Roboto:400,300,500,700,900" rel="stylesheet" type="text/css">
<link href="assets/css/master.css" rel="stylesheet">-->

<!-- HTML5 shim and Respond.js for IE8 support of HTML5 elements and media queries -->
<!-- WARNING: Respond.js doesn't work if you view the page via file:// -->
<!--[if lt IE 9]>
  <script src="https://oss.maxcdn.com/html5shiv/3.7.2/html5shiv.min.js"></script>
  <script src="https://oss.maxcdn.com/respond/1.4.2/respond.min.js"></script>
<![endif]-->
<script>
function ShowHide(){
document.GetElementById('field1').display='block';
}
 
</script>
<style>
.lookupIcon {
 background-image: url('{!$Resource.LookupIcon}') !important;
 height:30px !important;
 width:30px !important;
 position:absolute !important;
 top:6px !important;
 right:-25px !important;
}

.lookupIconOn {
 background-image: url('{!$Resource.LookupIcon}') !important;
 height:30px !important;
 width:30px !important;
 position:absolute !important;
 top:6px !important;
 right:-25px !important;
}

.SearchField{
background: #F6F6F6;
    height: 36px;
    border-radius: 6px;
    border: 1px solid #E1E1E1;
    padding: 0 15px;
    width: 20%;
    font-family: 'Roboto', sans-serif;
    font-size: 16px;
    font-weight: 400;
    }
</style>

    <script type="text/javascript">
        function selectAllCheckboxes(obj,receivedInputID){
            var inputCheckBox = document.getElementsByTagName("input");
            for(var i=0; i<inputCheckBox.length; i++){
                if(inputCheckBox[i].id.indexOf(receivedInputID)!=-1){
                    inputCheckBox[i].checked = obj.checked;
                }
            }
        }
    </script>
    
     <script type="text/javascript">
      function doSearch() {
      searchServer(
      document.getElementById("name").value
     
      );
  }
  </script>
  <script type="text/javascript">
        function validate() {
     
            {
              alert ( "Survey has been sent successfully" );
              
            }
        
            }
    </script>
    </head>
    
    <body>
    
<header class="mainHeader">
    <div class="container clear">
        <a href="/apex/SBIndex" class="logo"><img src="{!$Resource.MainLogo}" alt=""/></a>
        <div class="nav">
            <ul>
                <li><a href="/apex/SBIndex" class="home"><img src="{!$Resource.HomeIcon}" alt=""/></a></li>
                <li><a href="/apex/SBQuestionBank">Question Bank</a></li>
                <li><a href="/apex/SBCreateSurvey">Create Survey</a></li>
                <li class="active"><a href="/apex/SBSendSurvey">Send Survey</a></li>
                <li><a href="/00O50000004d9Np">Report</a></li>
            </ul>
        </div>
    </div>
</header>


<section class="page-name">
    <div class="container clear">
        <h2>All Contacts</h2>
    </div>
</section>

<section class="bodyContainer">
    <div class="container clear">
    
    <apex:form >
     <!--<apex:commandButton value="Add Contact" action="{!RedirectCon}" style="font-weight: bold;display: inline-block !important;padding: 3px 15px !important;line-height: 35px !important;color: #fff !important;font-size: 15px !important;background: #75C181 !important;border-radius: 35px !important; min-width: 125px !important;text-align: center !important; margin-left: 12px !important;   margin-bottom: 20px; float: right;"/>-->
 
     <!--<apex:commandButton value="Edit Template" action="{!Redirect}" style="font-weight: bold;display: inline-block !important;padding: 3px 15px !important;line-height: 35px !important;color: #fff !important;font-size: 15px !important;background: #75C181 !important;border-radius: 35px !important; min-width: 125px !important;text-align: center !important; margin-bottom: 20px; float: right;"/>-->
    
        
   <!-- For search -->
   
      <apex:outputLabel for="searchText">Search Contact</apex:outputLabel>&nbsp;&nbsp;
         <apex:panelGroup >
            <apex:inputText id="searchText" styleClass="SearchField" value="{!searchText}"/>&nbsp;&nbsp;
              <apex:commandButton value="Search" action="{!search}" styleClass="green-btn" style="font-weight: bold;"/>
         </apex:panelGroup>
         
   <!-- For search -->
    
       <apex:pageBlock >
        <apex:messages style="color:red;font-size:15px;" /><br />
        <div style="overflow: scroll; width:100%; height:300px;">
          <apex:pageBlockTable value="{!searchResults}" var="accWrap" id="table" width="100%" cellpadding="0" cellspacing="0" border="0" styleclass="defaultTable addquestionpage" style="overflow:scroll;">
                                     
                    <apex:column colspan="2">
                        <apex:facet name="header">
                            <apex:inputCheckbox onclick="selectAllCheckboxes(this,'inputId')"/>
                        </apex:facet>
                      <apex:inputCheckbox value="{!accWrap.selected}" id="inputId"/>
                    </apex:column>
                     
                   
                      <apex:column colspan="5" value="{!accWrap.acc.Name}" />
                    <apex:column colspan="5" value="{!accWrap.acc.Email}" />
                    <apex:column colspan="5" value="{!accWrap.acc.Phone}" />
          </apex:pageBlockTable>
          </div>
             
          <!--<apex:pageBlockTable value="{!selectedAccounts}" var="c" id="table2" width="100%" cellpadding="0" cellspacing="0" border="0" styleclass="defaultTable addquestionpage" style="margin-top:20px;">
                   <apex:column colspan="4" value="{!c.Id}" headerValue="Contact"/>
                    <apex:column colspan="4" value="{!c.Name}" headerValue="Contact Name"/>
                    <apex:column colspan="4" value="{!c.Email}" headerValue="Email"/>
                    <apex:column colspan="4" value="{!c.Phone}" headerValue="Phone"/>
           </apex:pageBlockTable>-->
        
          </apex:pageBlock>
      
         <div class="feild buttons">
                
                <apex:commandButton value="Send Survey" onclick="validate()"  action="{!processSelected}" styleClass="green-btn" rerender="table2" style="margin-top: 20px;font-weight: bold;"/>
                <apex:commandButton value="Cancel" action="{!CancelAction}" styleClass="red-btn" style="font-weight: bold;"/>
           
         </div>
         
         </apex:form>
     </div>
</section>

<footer class="main-footer">
    <ul>
        <li> <a href="#">Privacy Policy</a> </li>
        <li><a href="#">Terms of Services</a></li>
    </ul>
    <div class="copyright">© 2016 Survey Builder, All rights reserved. </div>
</footer>

<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.3/jquery.min.js"></script>
</body>
</html>

</apex:page>
Hello! 

I am working on the challenge for the BulkApexTriggers section and I keep receiving the following error. I am not sure what is wrong with my system. I have a Discount Percentage field under Accounts and Opportunities and that field is not required for the challenge. I received this error message for a lot of triggers I have tried to imput, and I'm not really sure what is going on. 

Challenge Not yet complete... here's what's wrong: 
There was an unexpected error in your org which is preventing this assessment check from completing: System.DmlException: Insert failed. First exception on row 0; first error: REQUIRED_FIELD_MISSING, Required fields are missing: [Discount_Percent__c]: [Discount_Percent__c]

Here is the Trigger I have entered into my Developer Console. 
trigger ClosedOpportunityTrigger on Opportunity (after insert, after update) {

    List<Task> taskList = new List<Task>();
    
    for (Opportunity opp : [SELECT Id, StageName FROM Opportunity WHERE StageName = 'Closed Won' AND Id IN :Trigger.new]){
                    
            taskList.add(new Task(Subject = 'Follow Up Test Task',
                                  WhatId = opp.Id));
       
    }

    if(taskList.size()>0){
        
        insert taskList;
        
    }
    
}

Thanks for your help! 
We know salesforce.com going to disable TLS1.0 in march in production environment.We hited already sandbox environment

I have a C# integration code ,I used recomeanded URL mentionted in the document ,but it was not working any inputs helpful

Dont post the recomenaded documentation content.

https://help.salesforce.com/HTViewSolution?id=000221207#MSFT

Wht is the work around.
  • August 25, 2016
  • Like
  • 0

I want functionality where if checkbox is checked then only email will send to desired user otherwise it will throw an error "Please select atleast one contact". How it is possible?
 

          <apex:pageBlockTable value="{!searchResults}" var="accWrap" id="table" >                                    
                    <apex:column colspan="2">
                      <apex:inputCheckbox value="{!accWrap.selected}" id="inputId"/> </apex:column>                   
                    <apex:column colspan="5" value="{!accWrap.acc.Name}" />
                    <apex:column colspan="5" value="{!accWrap.acc.Email}" />
                    <apex:column colspan="5" value="{!accWrap.acc.Phone}" />
          </apex:pageBlockTable>
     
Hello Eveyone,

I have created a visualforce page, in that I have a user lookup field and a button 
after selecting user, when I click on submit button I want to assign a permission set to that user(custom permission set). 
please help me on this.
Please telle me how to approach this.

Thanks in advance.
 
Hello,

I am trying to create a map of child objects as they relate to the parent object for a trigger.

I have the standard Contract object, and a custom Time Entry Object. When a Time Entry is created, udpated, or deleted my trigger kicks off and grabs all Time Entries associated with the Contract. It will then calculate the Total Time Entered and the Total Value and update this on the Contract. My current  method works, however I'm running into governor limit exceptions. Best practices states I should use a map instead of multipl SQL calls in a for loop. I've followed some examples online using this method however I am getting the error.

sObject type 'ContractwithTime' is not supported. If you are attempting to use a custom object, be sure to append the '__c' after the entity name. Please reference your WSDL or the describe call for the appropriate names.

Code:
trigger trg_TimeEntryRollupToContract on Time_Entry__c (after delete, after insert, after update) 
{
    double dblTotalHours = 0.0;
    double curTotalValue = 0.00;


    if(Trigger.isInsert||Trigger.isUpdate||Trigger.isDelete)
    { 
        //***********************************************
        //New Record
        //***********************************************
           
        if(Trigger.isInsert)
        { 


           List<Contract> ContractwithTime = [SELECT Id, Total_Time_Entry_Value__c, Total_Time_Entry_Hours__c,
                                                    (SELECT Id, Total_Time__c, Total_Entry_Value__c FROM TimeEntry__r)
                                                    FROM ContractwithTime WHERE Id IN :Trigger.newMap.KeySet()];
            
            for(Contract con : ContractwithTime){
                for(TimeEntry__c ti : ContractwithTime.Time_Entry__r){
                    	if (ti.Total_Time__c == null) ti.Total_Time__c = 0;
                        dblTotalHours += ti.Total_Time__c;
                        if(ti.Time_Entry_Value__c!=null) curTotalValue += ti.Time_Entry_Value__c;
                        if(dblTotalHours > 0) contractwithTime.Total_Time_Entry_Hours__c = dblTotalHours;
;
                        contractwithTime.Total_Time_Entry_Value__c = curTotalValue;
                }
            }
}



 
<apex:page standardController="Opportunity" recordSetVar="Oppo">
  <apex:form >
    <apex:pageBlock title="List of Opportunities">
     <apex:pageBlockTable value="{!Oppo}" var="o">
      <apex:column value="{!o.name}"/>
      <apex:column value="{!o.type}"/>
      <apex:column value="{!o.Account.Name}"/>
      <apex:column value="{!o.Account.Phone}"/>
      <apex:column value="{!o.StageName}"/>
      <apex:column value="{!o.Probability}"/>
      <apex:column value="{!o.ExpectedRevenue}"/>
     </apex:pageBlockTable>
     <apex:inlineEditSupport />
    </apex:pageBlock>
    <apex:commandButton value="Save" action="{!Quicksave}"/>
  </apex:form>
</apex:page>

This is my custom page. The changes done after editing the fields are not getting saved after i hit the Save button. There are no errors while saving the code. Please let me know the issue and the fix if you guys know of any.
Hello, I am writing a code where i want to show contact name as a link. so after clicking on the name i will go into org and edit delete the record. I want this on this line.   <apex:column colspan="5" value="{!accWrap.acc.Name}" /> Can anyone help me to achiev this?




<apex:page controller="ContactSelectClassController" sidebar="false" showHeader="false" standardStylesheets="false">
<html>
<head>
<meta charset="utf-8"/>
<meta http-equiv="X-UA-Compatible" content="IE=edge"/>
<meta name="viewport" content="width=device-width, initial-scale=1"/>
<title>Send Mail</title>
<apex:stylesheet value="https://fonts.googleapis.com/css?family=Roboto:400,300,500,700,900"/>
<apex:stylesheet value="{!$Resource.SurveyMaster}"/>
<apex:includeScript value="https://ajax.googleapis.com/ajax/libs/jquery/1.12.2/jquery.min.js"/ >
<!--<link href="https://fonts.googleapis.com/css?family=Roboto:400,300,500,700,900" rel="stylesheet" type="text/css">
<link href="assets/css/master.css" rel="stylesheet">-->

<!-- HTML5 shim and Respond.js for IE8 support of HTML5 elements and media queries -->
<!-- WARNING: Respond.js doesn't work if you view the page via file:// -->
<!--[if lt IE 9]>
  <script src="https://oss.maxcdn.com/html5shiv/3.7.2/html5shiv.min.js"></script>
  <script src="https://oss.maxcdn.com/respond/1.4.2/respond.min.js"></script>
<![endif]-->
<script>
function ShowHide(){
document.GetElementById('field1').display='block';
}
 
</script>
<style>
.lookupIcon {
 background-image: url('{!$Resource.LookupIcon}') !important;
 height:30px !important;
 width:30px !important;
 position:absolute !important;
 top:6px !important;
 right:-25px !important;
}

.lookupIconOn {
 background-image: url('{!$Resource.LookupIcon}') !important;
 height:30px !important;
 width:30px !important;
 position:absolute !important;
 top:6px !important;
 right:-25px !important;
}

.SearchField{
background: #F6F6F6;
    height: 36px;
    border-radius: 6px;
    border: 1px solid #E1E1E1;
    padding: 0 15px;
    width: 20%;
    font-family: 'Roboto', sans-serif;
    font-size: 16px;
    font-weight: 400;
    }
</style>

    <script type="text/javascript">
        function selectAllCheckboxes(obj,receivedInputID){
            var inputCheckBox = document.getElementsByTagName("input");
            for(var i=0; i<inputCheckBox.length; i++){
                if(inputCheckBox[i].id.indexOf(receivedInputID)!=-1){
                    inputCheckBox[i].checked = obj.checked;
                }
            }
        }
    </script>
    
     <script type="text/javascript">
      function doSearch() {
      searchServer(
      document.getElementById("name").value
     
      );
  }
  </script>
  <script type="text/javascript">
        function validate() {
     
            {
              alert ( "Survey has been sent successfully" );
              
            }
        
            }
    </script>
    </head>
    
    <body>
    
<header class="mainHeader">
    <div class="container clear">
        <a href="/apex/SBIndex" class="logo"><img src="{!$Resource.MainLogo}" alt=""/></a>
        <div class="nav">
            <ul>
                <li><a href="/apex/SBIndex" class="home"><img src="{!$Resource.HomeIcon}" alt=""/></a></li>
                <li><a href="/apex/SBQuestionBank">Question Bank</a></li>
                <li><a href="/apex/SBCreateSurvey">Create Survey</a></li>
                <li class="active"><a href="/apex/SBSendSurvey">Send Survey</a></li>
                <li><a href="/00O50000004d9Np">Report</a></li>
            </ul>
        </div>
    </div>
</header>


<section class="page-name">
    <div class="container clear">
        <h2>All Contacts</h2>
    </div>
</section>

<section class="bodyContainer">
    <div class="container clear">
    
    <apex:form >
     <!--<apex:commandButton value="Add Contact" action="{!RedirectCon}" style="font-weight: bold;display: inline-block !important;padding: 3px 15px !important;line-height: 35px !important;color: #fff !important;font-size: 15px !important;background: #75C181 !important;border-radius: 35px !important; min-width: 125px !important;text-align: center !important; margin-left: 12px !important;   margin-bottom: 20px; float: right;"/>-->
 
     <!--<apex:commandButton value="Edit Template" action="{!Redirect}" style="font-weight: bold;display: inline-block !important;padding: 3px 15px !important;line-height: 35px !important;color: #fff !important;font-size: 15px !important;background: #75C181 !important;border-radius: 35px !important; min-width: 125px !important;text-align: center !important; margin-bottom: 20px; float: right;"/>-->
    
        
   <!-- For search -->
   
      <apex:outputLabel for="searchText">Search Contact</apex:outputLabel>&nbsp;&nbsp;
         <apex:panelGroup >
            <apex:inputText id="searchText" styleClass="SearchField" value="{!searchText}"/>&nbsp;&nbsp;
              <apex:commandButton value="Search" action="{!search}" styleClass="green-btn" style="font-weight: bold;"/>
         </apex:panelGroup>
         
   <!-- For search -->
    
       <apex:pageBlock >
        <apex:messages style="color:red;font-size:15px;" /><br />
        <div style="overflow: scroll; width:100%; height:300px;">
          <apex:pageBlockTable value="{!searchResults}" var="accWrap" id="table" width="100%" cellpadding="0" cellspacing="0" border="0" styleclass="defaultTable addquestionpage" style="overflow:scroll;">
                                     
                    <apex:column colspan="2">
                        <apex:facet name="header">
                            <apex:inputCheckbox onclick="selectAllCheckboxes(this,'inputId')"/>
                        </apex:facet>
                      <apex:inputCheckbox value="{!accWrap.selected}" id="inputId"/>
                    </apex:column>
                     
                   
                      <apex:column colspan="5" value="{!accWrap.acc.Name}" />
                    <apex:column colspan="5" value="{!accWrap.acc.Email}" />
                    <apex:column colspan="5" value="{!accWrap.acc.Phone}" />
          </apex:pageBlockTable>
          </div>
             
          <!--<apex:pageBlockTable value="{!selectedAccounts}" var="c" id="table2" width="100%" cellpadding="0" cellspacing="0" border="0" styleclass="defaultTable addquestionpage" style="margin-top:20px;">
                   <apex:column colspan="4" value="{!c.Id}" headerValue="Contact"/>
                    <apex:column colspan="4" value="{!c.Name}" headerValue="Contact Name"/>
                    <apex:column colspan="4" value="{!c.Email}" headerValue="Email"/>
                    <apex:column colspan="4" value="{!c.Phone}" headerValue="Phone"/>
           </apex:pageBlockTable>-->
        
          </apex:pageBlock>
      
         <div class="feild buttons">
                
                <apex:commandButton value="Send Survey" onclick="validate()"  action="{!processSelected}" styleClass="green-btn" rerender="table2" style="margin-top: 20px;font-weight: bold;"/>
                <apex:commandButton value="Cancel" action="{!CancelAction}" styleClass="red-btn" style="font-weight: bold;"/>
           
         </div>
         
         </apex:form>
     </div>
</section>

<footer class="main-footer">
    <ul>
        <li> <a href="#">Privacy Policy</a> </li>
        <li><a href="#">Terms of Services</a></li>
    </ul>
    <div class="copyright">© 2016 Survey Builder, All rights reserved. </div>
</footer>

<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.3/jquery.min.js"></script>
</body>
</html>

</apex:page>
Hello Peeps
I am quite new in salesforce so please anyone can help me. I have to display the Accounts in checkbox and their related contacts in selectoptions. condition is that when i tick the checkbox of any account and click on the clone button the their related contacts will be cloned. sorry forgot to tell you i've to create a custom clone button too. And i have to do this by using wrapper and map. Proper code will be appriciated.

Thanx in Advance
Hello guys,

I am trying to do one of the examples in the Apex triggers where a SOQL query is used and I dont understand one of the parameters that is in line 6 which is:

06        [SELECT Id,(SELECT Id FROM Opportunities) FROM Account WHERE Id IN :Trigger.New]);

I dont understand the parameter "IN : Trigger.New])" ??, 

Complete Example:
01trigger AddRelatedRecord on Account(after insert, after update) {
02    List<Opportunity> oppList = new List<Opportunity>();
03     
04    // Get the related opportunities for the accounts in this trigger
05    Map<Id,Account> acctsWithOpps = new Map<Id,Account>(
06        [SELECT Id,(SELECT Id FROM Opportunities) FROM Account WHERE Id IN :Trigger.New]);
07     
08    // Add an opportunity for each account if it doesn't already have one.
09    // Iterate through each account.
10    for(Account a : Trigger.New) {
11        System.debug('acctsWithOpps.get(a.Id).Opportunities.size()=' + acctsWithOpps.get(a.Id).Opportunities.size());
12        // Check if the account already has a related opportunity.
13        if (acctsWithOpps.get(a.Id).Opportunities.size() == 0) {
14            // If it doesn't, add a default opportunity
15            oppList.add(new Opportunity(Name=a.Name + ' Opportunity',
16                                       StageName='Prospecting',
17                                       CloseDate=System.today().addMonths(1),
18                                       AccountId=a.Id));
19        }          
20    }
21 
22    if (oppList.size() > 0) {
23        insert oppList;
24    }
25}



I would really appreciate if anybody can help me. Thanks.
Hi I want to autopopulate a specific account on all the contacts where account name is left blank at the time of creation under two defined contact record types. 
Hello! 

I am working on the challenge for the BulkApexTriggers section and I keep receiving the following error. I am not sure what is wrong with my system. I have a Discount Percentage field under Accounts and Opportunities and that field is not required for the challenge. I received this error message for a lot of triggers I have tried to imput, and I'm not really sure what is going on. 

Challenge Not yet complete... here's what's wrong: 
There was an unexpected error in your org which is preventing this assessment check from completing: System.DmlException: Insert failed. First exception on row 0; first error: REQUIRED_FIELD_MISSING, Required fields are missing: [Discount_Percent__c]: [Discount_Percent__c]

Here is the Trigger I have entered into my Developer Console. 
trigger ClosedOpportunityTrigger on Opportunity (after insert, after update) {

    List<Task> taskList = new List<Task>();
    
    for (Opportunity opp : [SELECT Id, StageName FROM Opportunity WHERE StageName = 'Closed Won' AND Id IN :Trigger.new]){
                    
            taskList.add(new Task(Subject = 'Follow Up Test Task',
                                  WhatId = opp.Id));
       
    }

    if(taskList.size()>0){
        
        insert taskList;
        
    }
    
}

Thanks for your help! 
I'm creating an integration with Salesforce that just upserts a contact using an ID from my system. When my app user authorizes the oAuth integration in Salesforce I want to automatically create a new custom Contact field. Is that possible using the REST API? If so, how? Or is there an alternative automatic method I can use?

I'm using the restforce Ruby gem.
I am confused. If I look here:

https://developer.salesforce.com/docs/atlas.en-us.pages.meta/pages/pages_compref_repeat.htm

Then I see:

      <apex:repeat value="{!strings}" var="string" id="theRepeat">

And yet no variable called "strings" is ever defined in the controller:

public class repeatCon {
    public String[] getStrings() {
        return new String[]{'ONE','TWO','THREE'};
    }
}

In Ruby On Rails I would have to declare an instance variable in the controller, or I would get an error if I tried to use it in the view.

Where does {!strings} come from? The controller has no variable called "strings", so how can we use a variable called {strings}

I would have expected {!getStrings}. That would have made sense.
 
I'v created a class in sandbox, and it works well, but when i'm tring to deploy it to production, i get a low code covarage. I tried everything i know but cat find a solution, Heres the code, Any help?
 
public Class CandidateFileUploads_Ver1{

public String parentId ;
public String idxVal {get;set;}
public Map<String, Attachment> attachments {get;set;}
public Map<String, Attachment> attachmentsDup {get;set;}

public Boolean validateUser {get;set;}
public String multipulDocs {get;set;}
public String userMessage {get;set;}

private static final Map<String, String> descriptionNameMap = new Map<String, String>{
'Upload a scan of the Passport'=>'Passport',
'Upload a Resume (CV)'=>'Resume (CV)'};

private static final Map<String, String> descriptionCheckFieldMap = new Map<String, String>{
'Upload a scan of the Passport'=>'Passport_Attached__c',
'Upload a Resume (CV)'=>'CV_Attached__c'};


public CandidateFileUploads_Ver1(ApexPages.StandardController controller){

    idxVal = '';
    validateUser = true;
    multipulDocs = System.Label.multiple_docs;
    userMessage = '';

    checkUserValid();
    attachments = new Map<String, Attachment>();       
    attachmentsDup = new Map<String, Attachment>();  

    parentId = System.currentPageReference().getParameters().get('Id');
    //parentId = '0034E00000FVJzA';
    List<Attachment> existingAttachments = fetchAllAttachments(parentId);//get all attachements for thew user

    for(String key :descriptionNameMap.keySet()){
        String kokp = descriptionCheckFieldMap.get(key);
        attachments.put(key.toLowerCase(), new Attachment(parentId=parentId, Description=key, body=null,Name = kokp )) ;
    }    

    for(Attachment attach :existingAttachments){
        attach.body = null;
        attachments.put(attach.Description.toLowerCase(), attach);             
    }
}

 public void checkUserValid(){
    String hours = System.Label.hours;
    String whitelist = System.Label.whitelist;
    ID pId = System.currentPageReference().getParameters().get('Id');
    Boolean validateUser = true;
    String userMessage;

    Contact parenter = new Contact(Id=pId);
     // Validate Proccess status: get proccess string status
            String getStatus = parenter.Process_Status__c;
            String[] whitelistArr = whitelist.split(',');// split proccess string

             Boolean checkWhiteList = false;
             for(String val : whitelistArr){
                 if(val == getStatus) {
                     checkWhiteList = true;
                 }
             }

             if(validateUser != checkWhiteList){
                 validateUser = false;
                 userMessage = System.Label.error_not_premitted;
                 return;
             }

    //Validate Dates
            //Datetime  getLinktimestamp = (Datetime) contactSObject.get('linktimestamp__c');
            Datetime  getLinktimestamp = parenter.linktimestamp__c;
            Datetime  getValidTime = getLinktimestamp.addHours(Integer.valueof(hours.trim())); //add 48 hours
            Datetime timeNow = System.now();

             if(getValidTime < timeNow){//if if more then 48 hours
                 validateUser = false;
                 userMessage = System.Label.error_expired;
                 return;
             }
 }


 public Datetime  getLinktimestamp(){
    ID pId = System.currentPageReference().getParameters().get('Id');
    Datetime  accts = [SELECT linktimestamp__c FROM Contact WHERE Id=:pId].linktimestamp__c;
    return accts;
}


public List<Contact> contactObj(){
    ID pId = System.currentPageReference().getParameters().get('Id');

    sObject mySObject =[SELECT linktimestamp__c,Process_Status__c FROM Contact WHERE Id=:pId];
    //Datetime llli = s.linktimestamp__c;
    String strObjectName = String.valueOf( mySObject.get('linktimestamp__c') );

    List<Contact> obj = [SELECT linktimestamp__c,Process_Status__c FROM Contact WHERE Id=:pId];
    return obj;
}

public void uploadAttachment(){     
    List<Attachment> uploads = new List<Attachment>() ;
    List<Attachment> deletes = new List<Attachment>() ;

    try{
        for(integer i = 0 ; i < attachments.values().size() ; i++){

            Attachment attach = attachments.values()[i] ;
            if(attach.parentId == NULL){
                        attach.parentId = System.currentPageReference().getParameters().get('Id');
            }
            //this is a file that was uploaded now
            if(attach.body != NULL){
                //remove current attachement before uploading a new one
                if(attach.Id != NULL){
                    deletes.add(attachments.values().remove(i));
                }

                attach.Name = renameFile(attach.Name, attach.Description);
                uploads.add(attach) ;
            }
        }

        if(!deletes.isEmpty()){
            delete deletes ;
        }

        if(!uploads.isEmpty()){        
            for(Attachment atchmnt :uploads){
                atchmnt.Id = null;   
            }

            insert uploads;

            Contact parent = new Contact(Id=parentId);

            for(Attachment attach :getUpdatedAttachments(uploads).values()){
                attach.body = null;
                attachments.put(attach.Description.toLowerCase(), attach);

                parent.put(descriptionCheckFieldMap.get(attach.Description), true);                    
            }

            update parent;

            ApexPages.Message myMsg = new ApexPages.Message(ApexPages.Severity.info,'Attachment upload Successfully');
            ApexPages.addMessage(myMsg);
        }

    }        
    catch(exception e){
        ApexPages.Message myMsg = new ApexPages.Message(ApexPages.Severity.ERROR,'An Error occured when uploading attachment');
        ApexPages.addMessage(myMsg);
    }
}

public void removeRow(){
    Attachment a = attachments.get(idxVal.toLowerCase());

    Contact parent = new Contact(Id=parentId);
    parent.put(descriptionCheckFieldMap.get(a.Description), false); 

    delete a;
    update parent;

    system.debug('attachments before: ' + attachments);
    attachments.put(a.Description.toLowerCase(), new Attachment(parentId = parentId, description = a.description, body=null));
    system.debug('attachments after: ' + attachments);
}    

private static String renameFile(String fileName, String description){
    String newName = descriptionNameMap.get(description);
    if(String.isNotBlank(fileName) && fileName.contains('.')){
        newName += fileName.substring(fileName.lastIndexOf('.'), fileName.length());
    }

    return newName;
} 

private static Map<String,Attachment> getUpdatedAttachments(List<Attachment> attachList){

    Map<String,Attachment> attMap = new Map<String,Attachment>();

    for(Attachment att : [SELECT Id,Name,Description
                                      FROM Attachment
                                      WHERE Id = :attachList]){
        attMap.put(att.Description.toLowerCase(), att) ;       
    }

    return attMap;
}

public List<Attachment> fetchAllAttachments(String parentId){

    return [SELECT Id,Name,Description,parentId
            FROM Attachment 
            WHERE ParentId =: parentId 
            AND Description IN :descriptionNameMap.keySet()];
}
}

 
i have written a class,but both users are executing the class,but only user2 should insert the record what mistake is there in my class can annyone tell me.

class
public class inserting {
    public  void insertingrecords(string nm,decimal dd){
        Account a = new Account();
        a.name=nm;
        insert a;
    }
   
}

testclass using system.runas():
@isTest
private class TestRunAs {
   public static testMethod void testRunAs() {
      // Setup test data
      // This code runs as the system user
      Profile p = [SELECT Id,name FROM Profile WHERE Name='System Administrator']; 
               system.debug('values in p==='+'p.Name is '+p.name+'p.id is '+p.Id);
       
      /*User u = new User(Alias ='rprac', Email='sharath.kanukuntla1@gmail.com', 
      EmailEncodingKey='UTF-8', LastName='practise1', LanguageLocaleKey='en_US', 
      LocaleSidKey='en_US', ProfileId = p.Id, 
      TimeZoneSidKey='America/Los_Angeles', UserName='randheer.practise1@gmail.com');
      system.debug('user details are====== '+'email is '+u.Email+'Alias is '+u.Alias+'Profile id is '+u.ProfileId);
      
       System.runAs(u) {
         // The following code runs as user 'u' 
         System.debug('Current User: ' + UserInfo.getUserName());
         System.debug('Current Profile: ' + UserInfo.getProfileId()); 
      }*/
       User u3 = [SELECT Id FROM User WHERE UserName='randheer.practise1@gmail.com'];
         System.runAs(u3) {
             inserting obj = new inserting();
             obj.insertingrecords('sresht',12.22);
             System.debug('Current User: ' + UserInfo.getUserName());
             System.debug('Current Profile: ' + UserInfo.getProfileId()); 
             
         }
   }
}
 
How can i achieve below activity.
I have a button "close", when i click on close button i should get only close option in status field not any other options from status field.
 
We know salesforce.com going to disable TLS1.0 in march in production environment.We hited already sandbox environment

I have a C# integration code ,I used recomeanded URL mentionted in the document ,but it was not working any inputs helpful

Dont post the recomenaded documentation content.

https://help.salesforce.com/HTViewSolution?id=000221207#MSFT

Wht is the work around.
  • August 25, 2016
  • Like
  • 0