• Paras Prajapati
  • NEWBIE
  • 13 Points
  • Member since 2016

  • Chatter
    Feed
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 0
    Questions
  • 6
    Replies
Hi,
I want to display links just like shown in below(If we click on view, the student's marks sheet need to be displayed in another window)
Links


More Info:
 I am doing Integration, The school children Marks sheets are stored in a different database, 
I have received a URL for Integration.
I have placed them in Remote site settings.
What's next?
How do I receive that JSON file/Response?
Do I need to write any apex classes? Or can I just keep the URL in formula field? 
  • February 08, 2019
  • Like
  • 0
Hi All ,
i have created a batch to migrate case Comment from zendesk to salesforce.
My batch is given below:-
/*
* Batch to upsert Zendesk Organizations into salesforce caseComments
*/
public class BatchZendeskToSalesforceComments implements Database.Batchable<sObject>,Database.AllowsCallouts, Database.Stateful {
    // start method to return the list of end points of Zendesk CaseComments
        string query;
    public Database.querylocator start(Database.BatchableContext BC){
        query = 'SELECT Id, Name,parentid,commentbody,ispublished ' +
                'FROM caseComment ' +
                'WHERE parentid = \'500m0000008psIS\'  ';
        return Database.getQueryLocator(query);
    }
    //execute method to upsert CaseComments
    public void execute( Database.BatchableContext BC, List<caseComment> comments){
        getComments();
    }
    public void finish(Database.BatchableContext BC){
        
    }
    public static List< caseComment > getComments(){
        
        HttpRequest req = new HttpRequest();
        req.setMethod( 'GET' );
        String username = System.Label.Zendesk_UserName;
        String password = System.Label.Zendesk_Password;
        Blob headerValue = Blob.valueOf( username + ':' + password );
        String authorizationHeader = 'BASIC ' + EncodingUtil.base64Encode( headerValue );
        req.setHeader( 'Authorization', authorizationHeader );
        req.setHeader( 'Content-Type', 'application/json' );
        req.setEndpoint( 'https://timerack.zendesk.com/api/v2/tickets/14732/comments.json ' );
        Http binding = new Http();
        HttpResponse res = binding.send( req );
        
        Map<String, Object> results = ( Map<String, Object> )JSON.deserializeUntyped( res.getBody() );
        List<Object> lstComments = ( List<Object> )results.get( 'comments' );
        List<Map<String, Object>> commentsAtt = new List< Map< String, Object >>();
        for ( Object comment : lstComments ) {
            Map<String, Object> commentsAttributes = ( Map< String, Object >)comment;
            commentsAtt.add( commentsAttributes );
        }
        List< caseComment > listCommentToUpsert = new List< caseComment >();
        for( Map< String, Object> attMap : commentsAtt ){
            caseComment ct = new caseComment(); 
            ct.parentid = '500m0000008psIS';
            ct.commentbody = String.valueOf( attMap.get( 'body' ));
            ct.ispublished = true;
             listCommentToUpsert.add(ct);
            
        }
        return listCommentToUpsert;
     }
}
Can anyone help me out with this requirement?
any suggestions that i am using it right or am i missing something?

Hi,

I am trying to update orderTrigger on challenge 2, and  I am getting below error:
User-added image

Please find my trigger and helper class below. Any help would be highly appreciated.

orderTrigger:

/**
 * @name orderTrigger
 * @description
**/
trigger orderTrigger on Order (after update) {
    public Set<Id> orderIds = new Set<Id>();
    if(Trigger.new != null){
    	orderIds = OrderHelper.AfterUpdate(Trigger.new, Trigger.old);    
    }
    
    OrderHelper.RollUpOrderItems(orderIds);
    
}

OrderHelper:
public with sharing class OrderHelper {

    /**
     * @name AfterUpdate
     * @description 
     * @param List<Order> newList
     * @param List<Order> oldList
     * @return void
    **/
    public static Set<Id> AfterUpdate(List<Order> newList, List<Order> oldList){
        Set<Id> orderIds = new Set<Id>();
        for ( Integer i=0; i<newList.size(); i++ ){
            if ( newList[i].Status == 'Activate' && oldList[i].Status == 'Draft' ){
                orderIds.add(newList[i].Id);
            }
        }
        return orderIds;
    }

    /**
     * @name RollUpOrderItems
     * @description Given a set of Activated Order ids, query the child Order Items and related Products to calculate Inventory levels
     * @param Set<Id> activatedOrderIds
     * @return void
    **/
    public static void RollUpOrderItems(Set<Id> activatedOrderIds){
        Map<Id, Product2> productMap;
        Set<Id> product2Ids = new Set<Id>();
        List<OrderItem> orderItems = [SELECT Id, Quantity, Product2Id FROM OrderItem WHERE OrderId IN:activatedOrderIds];
        for(OrderItem item :orderItems){
            product2Ids.add(item.Product2Id);
        }
        productMap = new Map<Id, Product2>([SELECT Id, Quantity_Ordered__c FROM Product2 WHERE Id IN :product2Ids]);
        for(OrderItem item :orderItems) {
            if(productMap.containsKey(item.Product2Id)) {
                productMap.get(item.product2Id).Quantity_Ordered__c -= item.Quantity;
            }
        }
        update productMap.values();
    }

}
I have built the reports and dashboards as outlined in the requirements, but I'm getting the following error "Challenge Not yet complete... here's what's wrong: Couldn't find a component with the title 'My Top Accounts'."  
User-added image

However, I have the component on the dashboard as you can see below.
User-added image
What am I missing?
I'm unable to check step 2: Automate Accounts because I'm receiving this error: Challenge Not yet complete... here's what's wrong: 
There was an unexpected error while verifying this challenge. Usually this is due to some pre-existing configuration or code in the challenge Org. We recommend using a new Developer Edition (DE) to check this challenge. If you're using a new DE and seeing this error, please post to the developer forums and reference error id: ZKCVFIZH