• Steve Loudermilk
  • NEWBIE
  • 10 Points
  • Member since 2016

  • Chatter
    Feed
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 3
    Questions
  • 6
    Replies
I am basically writing that attachment ID to a custome field so I can display it on a page.  I have the trigger written which I will add below, but I am having trouble with the test class. I went down the pat of "loading" in a record an attachment, but haven't managed to get coverage yet.  If someoen could help me out I would be very appreciative.

Thanks in advance,

Milk
 
trigger MoveAttachmentIDforFormula on Attachment (after insert) {
    Map<Id, Id> mapCSId = new map<Id, Id>();
    List<InspectTHIS__Applied_Questionnaire__c> dct = new List<InspectTHIS__Applied_Questionnaire__c>();
    String objectName = '';
    for(Attachment atc: trigger.new){
        String myIdPrefix = string.valueOf(atc.ParentId).substring(0,3);
        Map<String, Schema.SObjectType> gd =  Schema.getGlobalDescribe(); 
        for(Schema.SObjectType stype : gd.values()){
            Schema.DescribeSObjectResult r = stype.getDescribe();
            String prefix = r.getKeyPrefix();
            if(prefix!=null && prefix.equals(myIdPrefix)){
                objectName = r.getName();
            }
        }
        if(objectName == 'InspectTHIS__Applied_Questionnaire__c'){
            mapCSId.put(atc.ParentId, atc.id);
        }
    }
    if(!mapCSId.isEmpty()){
        List<InspectTHIS__Applied_Questionnaire__c> lstdct = [select id from InspectTHIS__Applied_Questionnaire__c where id in: mapCSId.keyset()];
        for(InspectTHIS__Applied_Questionnaire__c cs: lstdct){
            cs.AttachmentId__c = mapCSId.get(cs.id);
        }
        if(!lstdct.isEmpty()){
            update lstdct;
        }
    }
    
}

 
global class SignOffController {
    Daily_Crane_Ticket__c ticket {get; set; }
    global SignOffCOntroller(ApexPages.StandardController controller){
        ticket = (Daily_Crane_Ticket__c)controller.getRecord();
    }
    @RemoteAction
    global static void submitSignature(String name, String body, String parentId, String fullName, String email){
       
        ConnectApi.FeedItemInput input = new ConnectApi.FeedItemInput();
        input.subjectId = parentId;
        
        ConnectApi.ContentCapabilityInput contentInput = new ConnectApi.ContentCapabilityInput();
        contentInput.title = 'Signature';
        
        ConnectApi.FeedElementCapabilitiesInput capabilities = new ConnectApi.FeedElementCapabilitiesInput();
        capabilities.content = contentInput;
        
        input.capabilities = capabilities;
        
        Blob myBlob = EncodingUtil.base64Decode(body);
        ConnectApi.BinaryInput binInput = new ConnectApi.BinaryInput(myBlob, 'img/png', 'Site Check-In.png');
        
        ConnectApi.ChatterFeeds.postFeedElement(Network.getNetworkId(), input, binInput);
        
        Daily_Crane_Ticket__c ticket = new Daily_Crane_Ticket__c();
        try{
            ticket = [SELECT Id,Signer_Name__c,Signer_Email__c FROM Daily_Crane_Ticket__c WHERE Id = :parentId][0];
        } catch (QueryException e){
            System.Debug(e);
        }
        if(ticket != null){
            ticket.Signer_Email__c = email;
            ticket.Signer_Name__c = fullName;
        	update ticket;
        }
        
        //return a.Id;

        
    }
This some code one of my colleagues put together last year so it runs off an older version of the API(v35.0).  I am having issues with testing this code and I've taken several shots at I just can't seem to get it figured out.  I'm fairly new to apex and need some direction or help here.  I've looked through the documentation on the subject as well as some Github resources.

Thanks in advance.
Hello everyone,

I am new to working with visualforce controllers and need a little help with a test class.

This is my code which is fairly simple, just not sure how to work with as far as getting code coverage.

public class CraneTicketID {
    public Daily_Crane_Ticket__c currentrecord {get; set;}
    
   
    public CraneTicketID(ApexPages.StandardController controller) {
        currentRecord = [SELECT Id  FROM Daily_Crane_Ticket__c WHERE Id = :ApexPages.currentPage().getParameters().get('id')];
    }

}

Any help is appreciated.
I am basically writing that attachment ID to a custome field so I can display it on a page.  I have the trigger written which I will add below, but I am having trouble with the test class. I went down the pat of "loading" in a record an attachment, but haven't managed to get coverage yet.  If someoen could help me out I would be very appreciative.

Thanks in advance,

Milk
 
trigger MoveAttachmentIDforFormula on Attachment (after insert) {
    Map<Id, Id> mapCSId = new map<Id, Id>();
    List<InspectTHIS__Applied_Questionnaire__c> dct = new List<InspectTHIS__Applied_Questionnaire__c>();
    String objectName = '';
    for(Attachment atc: trigger.new){
        String myIdPrefix = string.valueOf(atc.ParentId).substring(0,3);
        Map<String, Schema.SObjectType> gd =  Schema.getGlobalDescribe(); 
        for(Schema.SObjectType stype : gd.values()){
            Schema.DescribeSObjectResult r = stype.getDescribe();
            String prefix = r.getKeyPrefix();
            if(prefix!=null && prefix.equals(myIdPrefix)){
                objectName = r.getName();
            }
        }
        if(objectName == 'InspectTHIS__Applied_Questionnaire__c'){
            mapCSId.put(atc.ParentId, atc.id);
        }
    }
    if(!mapCSId.isEmpty()){
        List<InspectTHIS__Applied_Questionnaire__c> lstdct = [select id from InspectTHIS__Applied_Questionnaire__c where id in: mapCSId.keyset()];
        for(InspectTHIS__Applied_Questionnaire__c cs: lstdct){
            cs.AttachmentId__c = mapCSId.get(cs.id);
        }
        if(!lstdct.isEmpty()){
            update lstdct;
        }
    }
    
}

 
Need to create a new report type has been requested linking  two objects "X" & "Y" . This report should contain all "X" objects as well as the fields associated to them by a common Sales Order number.
The link between these two objects should be as follows:
Order Number ("X") = SAP ID ("Y")
NOTE: Order Number will have 3 leading zeroes where as SAP ID will not, some logic needs to applied through the report link to remove these zeroes to ensure the link works properly.

HOW do i achieve it.. kindly suggest as im new to it
IF(OR(NOT(ISNULL(Win_Rate_Value__c)),NOT(ISNULL(Amount))),(Win_Rate_Value__c / Amount) , 00)

User-added image
Hello everyone,

I am new to working with visualforce controllers and need a little help with a test class.

This is my code which is fairly simple, just not sure how to work with as far as getting code coverage.

public class CraneTicketID {
    public Daily_Crane_Ticket__c currentrecord {get; set;}
    
   
    public CraneTicketID(ApexPages.StandardController controller) {
        currentRecord = [SELECT Id  FROM Daily_Crane_Ticket__c WHERE Id = :ApexPages.currentPage().getParameters().get('id')];
    }

}

Any help is appreciated.