• Swaggy B
  • NEWBIE
  • 10 Points
  • Member since 2014

  • Chatter
    Feed
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 10
    Questions
  • 6
    Replies
I have a component with some field and what not on there, basically I am trying to get a button to click using Shift + c, I have setup the short key via the app. this is what i have in my Component and Script. the ID of my component is called theComponent and the page where I use the component, id is called thePage. when i hit Shift + C nothing happens. 

<script>
sforce.console.addEventListener('SHIFT+C', function() {
                document.getElementById(
                        '{!$Component.thePage.externalComponentId.theComponent.theForm.pageBlockSection.blockButtons.addContact}').click();
            });
    </script>
    <apex:form id="theForm">
    
        <apex:pageBlock mode="detail" id="pageBlockSection" rendered="{!!currentContact}" >
            <apex:pageBlockButtons id="blockButtons">
                <apex:actionStatus id="finishChangedNew" onstart="openPopUp()"/>
                <apex:commandButton id="addContact" alt="Add Contact" value="Add Contact" action="{!addContact}" status="finishChangedNew" onclick="document.getElementById('{!$Component.thePage.externalComponentId.theComponent.theForm.contactId}').value = '';"  />
                <br></br>......etc. </apex:form>
I have a component with some fields and what not on there, basically I am trying to get a button to click using Shift + c, I have setup the short key via the app. this is what i have in my Component and Script. the ID of my component is called theComponent and the page where I use the component, id is called thePage. when i hit Shift + C nothing happens. 

<script>
sforce.console.addEventListener('SHIFT+C', function() {
                document.getElementById(
                        '{!$Component.thePage.externalComponentId.theComponent.theForm.pageBlockSection.blockButtons.addContact}').click();
            });
    </script>
    <apex:form id="theForm">
    
        <apex:pageBlock mode="detail" id="pageBlockSection" rendered="{!!currentContact}" >
            <apex:pageBlockButtons id="blockButtons">
                <apex:actionStatus id="finishChangedNew" onstart="openPopUp()"/>
                <apex:commandButton id="addContact" alt="Add Contact" value="Add Contact" action="{!addContact}" status="finishChangedNew" onclick="document.getElementById('{!$Component.thePage.externalComponentId.theComponent.theForm.contactId}').value = '';"  />
                <br></br>......etc. </apex:form>
Trying to figure out somehelp on how I can copy the attachments when I clone a opportunity from the original opp. I created a field called Clone_Helper__c that has a workflow rule which evalutes true if it is blank and does a field up date to populate that field with the Orginal opp id.
right now I just have some test stuff in there to see if it would just make a new attachment. 

 if(trigger.isBefore){
        Set<Id> OppsID = new Set<Id>();
        for(Opportunity cloneOpp: Trigger.new){
            if(cloneOpp.Clone_Helper__c != null){
               OppsId.add(cloneOpp.id);
            }
        }
        if(!OppsID.isEmpty()){
            Map<id,Opportunity> oppMap = new Map<id,Opportunity>([Select Clone_Helper__C From Opportunity Where Id IN :OppsId]);
           
            List<Attachment> attachments = new List<Attachment>();
            Attachment thisAttch = new Attachment();
            thisAttch.Name = 'Unit Test Attachment';
            Blob bodyBlob = Blob.valueOf('Unit Test Attachment Body');
            thisAttch.body = bodyBlob;
            thisAttch.parentId = ??
            thisAttch.Description = 'ABC';
            insert thisAttch;
         
           }
      
        }
Hello I have a class that I am trying to get some test coverage from that is using a http response. Here is my class 

public with sharing class APIApplicationUtility {

    public static DTOApplication createApplication (DTOApplication reqApplication){
        DTOApplication returnApplication = new DTOApplication();

        try{

            String endPoint='http://hcscdn-dev.apigee.net/retailapi/v1-dev/application/application';

            if(!Test.isRunningTest()){

            }

            HttpRequest req=new HttpRequest();
            req.setEndpoint(endPoint);
            req.setMethod('POST');
            req.setCompressed(false);
            req.setHeader('Content-Type','application/hal+json');
            String jsonBody = JSON.serialize(reqApplication);
            req.setBody(jsonBody);

            //Where going to call the API here
            HttpResponse r = OAuthUtility.InvokeService(req,false);

            if (r == null){
                DTOError er = new DTOError ('There was a problem with the Application service. Please call an administrator.');
                returnApplication.errors.add(er);
                return returnApplication;
            }

            String jsonStr = r.getBody();
            system.debug('Quote Response: '+jsonStr);

            //Deserialize JSON back to DTO class
            returnApplication = (DTOApplication)System.JSON.deserialize(jsonStr, DTOApplication.class);
        }catch (Exception e){
            system.debug(e);
            DTOError er = new DTOError(e.getMessage());
            returnApplication.errors.add(er);
        }
        return returnApplication;
    }

I wrote a mock also 
@isTest
global class TestApplicationAPIMock implements HttpCalloutMock {
    global HttpResponse respond(HttpRequest req){

        //Create a fake response

        HttpResponse res = new HttpResponse();
        res.setHeader('Content-type', 'application/json');
        res.setBody('{"applicationType"}:"major_med"}');
        res.setStatusCode(200);

        return res;

    }

}

And here is the start of my test class

@isTest
public class APIApplicationUtilityTest {
    
    @isTest static void TestAPIApplication(){

           Test.setMock(HttpCalloutMock.class, new TestApplicationAPIMock());

           APIApplicationUtility thisApp = new APIApplicationUtility();

          HttpResponse r = APIApplicationUtility.createApplication();
      
    }
    
    
}

Im having problems getting the method.
I have a lookup field that looks up to opportunity on the opportunity object, that is not firing a trigger. any thoughts???
I have this trigger that i created but i am unable to figure out how to get the query out of the for loop, my trigger will run but i know it will hit some governer limits. 

trigger AcceptJobAndCreateEmployee on Candidate_Application__c (after update) {
    
    //This will be the list to add the new candidate
    List<Account> accounts = new List<Account>();

    //Query for the Account Record Types
    List<RecordType> rtypes = [Select name, id FROM RecordType WHERE sObjectType = 'Account' AND IsPersonType = True];
   
    Map<String,String> accountRecordTypes = new Map<String,String>();
        for(RecordType rt: rtypes){
            accountRecordTypes.put(rt.Name,rt.id);
        }
        
    

    for(Candidate_Application__c thisApplication: Trigger.new)
    {
        Candidate_Application__c oldApp = Trigger.oldMap.get(thisApplication.id);
        Boolean AppFalse = oldapp.Job_Accepted__c;
        Boolean AppTrue = thisApplication.Job_Accepted__c;
        
       List <Candidate__c> newCandidates = [Select id, name FROM Candidate__C WHERE id =: thisApplication.Candidate__c]; 
        
        if(!AppFalse && AppTrue)
        {            
            if(newCandidates.size() > 0){
                Account converted = new Account();
            
            
                converted.RecordTypeid = accountRecordTypes.get('Person Account');
                converted.LastName = newCandidates.get(0).Name;
                converted.Phone = newCandidates.get(0).Phone__c;
              
                
                accounts.add(converted);
                
            }
            

        }

    }

    insert accounts;
}
Hello I was trying to hide the search bar in the community based on the Id I have some Jquery that I am able to inject in the footer to get rid of the search bar but i am having problems doing it based on the profile Id. 


<html>
<head>
    <meta charset="utf-8">
    
</head>
<body>
<script src="//code.jquery.com/jquery-1.11.2.min.js"></script>
<script src="//code.jquery.com/jquery-migrate-1.2.1.min.js"></script>

    

<script type="text/javascript">
/* Hide the top search box */

var j$ = jQuery.noConflict();

j$(document).ready(function(){

if('{!$User.Profile}' == 'Windstream Community User'){

j$("#phSearchContainer").hide();
}
}); 

</script>
</body>
</html>
 
Hello i am trying to show Custom Related list from a Custom Object in a visualforce page that is in a community. I believe i have everything right but the fields are not showing or retreiving anything for the last two page blocks here is my code

<apex:page controller="CommunityProjectController" showHeader="false" sidebar="false">
    <apex:composition template="CommunityPageTemplate">
    <apex:define name="bodyContent">
    <apex:form >
        <apex:pageBlock >
       
        
        <apex:pageBlockTable value="{!thisProject}" var="item" columns="6">
            <apex:column headerValue="Project Name">
                <apex:outputLink value="/apex/SMBCommunityProject?Projectid={!item.id}">{!item.Name}</apex:outputLink>
            </apex:column>
            <apex:column value="{!item.Area__c}"/>
            
            <apex:column value="{!item.Project_Sub_Class__c}"/>
            <apex:column value="{!item.Status__c}"/>
            <apex:column value="{!item.Technical_Lead__c}"/>
            <apex:column value="{!item.Primary_Contact__c}"/>
        </apex:pageBlockTable>
        </apex:pageBlock>
       
        <apex:pageBlock >
        <apex:pageBlockTable value="{!thisProject}" var="item" columns="5">
            
            <apex:column value="{!item.Budget__c}"/>
            <apex:column value="{!item.Contingency__c}"/>
            <apex:column value="{!item.Total_Budget__c}"/>
            <apex:column value="{!item.Total_Invoiced__c}"/>
            <apex:column value="{!item.Budget_Remaining__c}"/>
        </apex:pageBlockTable>
        </apex:pageblock>
        
        <apex:pageBlock >
        <apex:pageBlockTable value="{!invoices}" var="item" columns="6">
            <apex:column >
                <apex:outputLink value="/apex//apex/printableinvoice?id={!item.id}" >{!item.Name}</apex:outputLink>
            </apex:column>
            <apex:column value="{!item.Invoice_Date__c}"/>
            
            <apex:column value="{!item.Payment_Terms__c}"/>
            <apex:column value="{!item.Invoice_Due_Date__c}"/>
            <apex:column value="{!item.Invoice_Total__c}"/>
            <apex:column value="{!item.Status__c}"/>
            <apex:column value="{!item.Project__c}"/>
        </apex:pageBlockTable>
        </apex:pageBlock>

        

        <apex:pageBlock >
        <apex:pageBlockTable value="{!changeOrders}" var="item" columns="6">
            <apex:column value="{!item.name}" />
            <apex:column value="{!item.Status__c}"/>
            <apex:column value="{!item.Amount__c}"/>
            <apex:column value="{!item.Date_Requested__c}"/>
            <apex:column value="{!item.Date_Approved__c}"/>
            <apex:column value="{!item.Approval_Method__c}"/>
        </apex:pageBlockTable>
        

       
            
        </apex:pageBlock>
    
    </apex:form>

    </apex:define>
    </apex:composition>

</apex:page>

--------------------------------------------------------------------------------------------------------------------------------------
/*
    This class will handle grabbing a passed in projectid as a url parameter, then display the info
*/
public with sharing class CommunityProjectController{

    public Project__c thisProject {get;set;}
    public List<Change_Order__c> changeOrders {get;set;}
    public List<Invoice__c> invoices {get;set;}
    public String thisProjectId {get;set;}

    public CommunityProjectController()
    {
    
        //get our projectId parameter, use it to query for our project and set it to "thisProject"
        thisProjectId = ApexPages.currentPage().getParameters().get('projectId');

        thisProject = [SELECT id, name, Area__c, Project_Sub_Class__c, Status__c, Technical_Lead__c, Primary_Contact__c, 
                        Budget__c, Contingency__c, Total_Budget__c, Total_Invoiced__c, Budget_Remaining__c FROM Project__c WHERE id =: thisProjectId];
         
      
        
        changeOrders = [SELECT id, Name, Status__c, Amount__c, Date_Requested__C, Date_Approved__c, Approval_Method__c FROM Change_Order__c WHERE id =:thisProjectId];

        for(Change_Order__c currentChangeOrder : changeOrders)
        {

        }

        invoices = [SELECT id, Name, Invoice_Date__c, Payment_Terms__c, Invoice_Due_Date__c, Invoice_Total__c, Status__c, Project__c FROM Invoice__c WHERE id =: thisProjectId];

        for(Invoice__c currentInvoice : invoices)
        {

        }

        
    }

}
Is there any type of way to send a email with an attachment and automaically have it attached to the Notes & Attachments section.
I have a custom knowledge page and I am trying to get the Most viewed by all users to show up like this.

 User-added image
Here is what I have as my controller
public with sharing class vfKeywordSearchController {

//Page Size
private Static Final Integer PAGE_NUMBER = 10;

  //Search String used in ArticleList tag
public String searchstring { get; set; }

public vfKeywordSearchController() {
String qryString = 'SELECT Id, title, UrlName, LastPublishedDate, LastModifiedById FROM KnowledgeArticleVersion WHERE (PublishStatus = \'online\' and Language = \'en_US\')';
  List<KnowledgeArticleVersion> articleList= Database.query(qryString);
  maxSize = articleList.size() ;
}

//Keeps track of current page & max size of article list
Integer currentPage = 1;
Integer maxSize = 1;

// Returns whether we need to see previous button or not
public boolean getPrevRequired() {
  return currentPage > 1;
}

// Returns whether we need to see next button or not
public boolean getNextRequired() {
  return currentPage * PAGE_NUMBER < maxSize;
}

//Returns current page number
public Decimal getCurrentPageNumber() {
  return this.currentPage;
}

//action for next click
public PageReference next() {
  if(maxSize > this.currentPage * PAGE_NUMBER) {
   this.currentPage = this.currentPage + 1;
  }
  return null;
}   

//action for previous click
public PageReference previous() {       
  if(this.currentPage > 1)
   this.currentPage = this.currentPage - 1;
  return null;
}


}

I have a component with some field and what not on there, basically I am trying to get a button to click using Shift + c, I have setup the short key via the app. this is what i have in my Component and Script. the ID of my component is called theComponent and the page where I use the component, id is called thePage. when i hit Shift + C nothing happens. 

<script>
sforce.console.addEventListener('SHIFT+C', function() {
                document.getElementById(
                        '{!$Component.thePage.externalComponentId.theComponent.theForm.pageBlockSection.blockButtons.addContact}').click();
            });
    </script>
    <apex:form id="theForm">
    
        <apex:pageBlock mode="detail" id="pageBlockSection" rendered="{!!currentContact}" >
            <apex:pageBlockButtons id="blockButtons">
                <apex:actionStatus id="finishChangedNew" onstart="openPopUp()"/>
                <apex:commandButton id="addContact" alt="Add Contact" value="Add Contact" action="{!addContact}" status="finishChangedNew" onclick="document.getElementById('{!$Component.thePage.externalComponentId.theComponent.theForm.contactId}').value = '';"  />
                <br></br>......etc. </apex:form>
Hello I have a class that I am trying to get some test coverage from that is using a http response. Here is my class 

public with sharing class APIApplicationUtility {

    public static DTOApplication createApplication (DTOApplication reqApplication){
        DTOApplication returnApplication = new DTOApplication();

        try{

            String endPoint='http://hcscdn-dev.apigee.net/retailapi/v1-dev/application/application';

            if(!Test.isRunningTest()){

            }

            HttpRequest req=new HttpRequest();
            req.setEndpoint(endPoint);
            req.setMethod('POST');
            req.setCompressed(false);
            req.setHeader('Content-Type','application/hal+json');
            String jsonBody = JSON.serialize(reqApplication);
            req.setBody(jsonBody);

            //Where going to call the API here
            HttpResponse r = OAuthUtility.InvokeService(req,false);

            if (r == null){
                DTOError er = new DTOError ('There was a problem with the Application service. Please call an administrator.');
                returnApplication.errors.add(er);
                return returnApplication;
            }

            String jsonStr = r.getBody();
            system.debug('Quote Response: '+jsonStr);

            //Deserialize JSON back to DTO class
            returnApplication = (DTOApplication)System.JSON.deserialize(jsonStr, DTOApplication.class);
        }catch (Exception e){
            system.debug(e);
            DTOError er = new DTOError(e.getMessage());
            returnApplication.errors.add(er);
        }
        return returnApplication;
    }

I wrote a mock also 
@isTest
global class TestApplicationAPIMock implements HttpCalloutMock {
    global HttpResponse respond(HttpRequest req){

        //Create a fake response

        HttpResponse res = new HttpResponse();
        res.setHeader('Content-type', 'application/json');
        res.setBody('{"applicationType"}:"major_med"}');
        res.setStatusCode(200);

        return res;

    }

}

And here is the start of my test class

@isTest
public class APIApplicationUtilityTest {
    
    @isTest static void TestAPIApplication(){

           Test.setMock(HttpCalloutMock.class, new TestApplicationAPIMock());

           APIApplicationUtility thisApp = new APIApplicationUtility();

          HttpResponse r = APIApplicationUtility.createApplication();
      
    }
    
    
}

Im having problems getting the method.
I have this trigger that i created but i am unable to figure out how to get the query out of the for loop, my trigger will run but i know it will hit some governer limits. 

trigger AcceptJobAndCreateEmployee on Candidate_Application__c (after update) {
    
    //This will be the list to add the new candidate
    List<Account> accounts = new List<Account>();

    //Query for the Account Record Types
    List<RecordType> rtypes = [Select name, id FROM RecordType WHERE sObjectType = 'Account' AND IsPersonType = True];
   
    Map<String,String> accountRecordTypes = new Map<String,String>();
        for(RecordType rt: rtypes){
            accountRecordTypes.put(rt.Name,rt.id);
        }
        
    

    for(Candidate_Application__c thisApplication: Trigger.new)
    {
        Candidate_Application__c oldApp = Trigger.oldMap.get(thisApplication.id);
        Boolean AppFalse = oldapp.Job_Accepted__c;
        Boolean AppTrue = thisApplication.Job_Accepted__c;
        
       List <Candidate__c> newCandidates = [Select id, name FROM Candidate__C WHERE id =: thisApplication.Candidate__c]; 
        
        if(!AppFalse && AppTrue)
        {            
            if(newCandidates.size() > 0){
                Account converted = new Account();
            
            
                converted.RecordTypeid = accountRecordTypes.get('Person Account');
                converted.LastName = newCandidates.get(0).Name;
                converted.Phone = newCandidates.get(0).Phone__c;
              
                
                accounts.add(converted);
                
            }
            

        }

    }

    insert accounts;
}
Hello i am trying to show Custom Related list from a Custom Object in a visualforce page that is in a community. I believe i have everything right but the fields are not showing or retreiving anything for the last two page blocks here is my code

<apex:page controller="CommunityProjectController" showHeader="false" sidebar="false">
    <apex:composition template="CommunityPageTemplate">
    <apex:define name="bodyContent">
    <apex:form >
        <apex:pageBlock >
       
        
        <apex:pageBlockTable value="{!thisProject}" var="item" columns="6">
            <apex:column headerValue="Project Name">
                <apex:outputLink value="/apex/SMBCommunityProject?Projectid={!item.id}">{!item.Name}</apex:outputLink>
            </apex:column>
            <apex:column value="{!item.Area__c}"/>
            
            <apex:column value="{!item.Project_Sub_Class__c}"/>
            <apex:column value="{!item.Status__c}"/>
            <apex:column value="{!item.Technical_Lead__c}"/>
            <apex:column value="{!item.Primary_Contact__c}"/>
        </apex:pageBlockTable>
        </apex:pageBlock>
       
        <apex:pageBlock >
        <apex:pageBlockTable value="{!thisProject}" var="item" columns="5">
            
            <apex:column value="{!item.Budget__c}"/>
            <apex:column value="{!item.Contingency__c}"/>
            <apex:column value="{!item.Total_Budget__c}"/>
            <apex:column value="{!item.Total_Invoiced__c}"/>
            <apex:column value="{!item.Budget_Remaining__c}"/>
        </apex:pageBlockTable>
        </apex:pageblock>
        
        <apex:pageBlock >
        <apex:pageBlockTable value="{!invoices}" var="item" columns="6">
            <apex:column >
                <apex:outputLink value="/apex//apex/printableinvoice?id={!item.id}" >{!item.Name}</apex:outputLink>
            </apex:column>
            <apex:column value="{!item.Invoice_Date__c}"/>
            
            <apex:column value="{!item.Payment_Terms__c}"/>
            <apex:column value="{!item.Invoice_Due_Date__c}"/>
            <apex:column value="{!item.Invoice_Total__c}"/>
            <apex:column value="{!item.Status__c}"/>
            <apex:column value="{!item.Project__c}"/>
        </apex:pageBlockTable>
        </apex:pageBlock>

        

        <apex:pageBlock >
        <apex:pageBlockTable value="{!changeOrders}" var="item" columns="6">
            <apex:column value="{!item.name}" />
            <apex:column value="{!item.Status__c}"/>
            <apex:column value="{!item.Amount__c}"/>
            <apex:column value="{!item.Date_Requested__c}"/>
            <apex:column value="{!item.Date_Approved__c}"/>
            <apex:column value="{!item.Approval_Method__c}"/>
        </apex:pageBlockTable>
        

       
            
        </apex:pageBlock>
    
    </apex:form>

    </apex:define>
    </apex:composition>

</apex:page>

--------------------------------------------------------------------------------------------------------------------------------------
/*
    This class will handle grabbing a passed in projectid as a url parameter, then display the info
*/
public with sharing class CommunityProjectController{

    public Project__c thisProject {get;set;}
    public List<Change_Order__c> changeOrders {get;set;}
    public List<Invoice__c> invoices {get;set;}
    public String thisProjectId {get;set;}

    public CommunityProjectController()
    {
    
        //get our projectId parameter, use it to query for our project and set it to "thisProject"
        thisProjectId = ApexPages.currentPage().getParameters().get('projectId');

        thisProject = [SELECT id, name, Area__c, Project_Sub_Class__c, Status__c, Technical_Lead__c, Primary_Contact__c, 
                        Budget__c, Contingency__c, Total_Budget__c, Total_Invoiced__c, Budget_Remaining__c FROM Project__c WHERE id =: thisProjectId];
         
      
        
        changeOrders = [SELECT id, Name, Status__c, Amount__c, Date_Requested__C, Date_Approved__c, Approval_Method__c FROM Change_Order__c WHERE id =:thisProjectId];

        for(Change_Order__c currentChangeOrder : changeOrders)
        {

        }

        invoices = [SELECT id, Name, Invoice_Date__c, Payment_Terms__c, Invoice_Due_Date__c, Invoice_Total__c, Status__c, Project__c FROM Invoice__c WHERE id =: thisProjectId];

        for(Invoice__c currentInvoice : invoices)
        {

        }

        
    }

}