• Andrew Gray
  • NEWBIE
  • 10 Points
  • Member since 2015

  • Chatter
    Feed
  • 0
    Best Answers
  • 3
    Likes Received
  • 0
    Likes Given
  • 5
    Questions
  • 2
    Replies
Hi 

I am trying to run this apex from Process builder:

public with sharing class sovosapi {
    
    @InvocableMethod

    public static void getworkflow() {
                        
             String workflowResponse; 
            String errorMessage;
            String generatedToken;
                
        // Generate new access token before calling bellow API
        generatedToken = sovostoken.getTokenFromSovos(); 
        System.debug('token '+ generatedToken);
        if(generatedToken == null ) {
            workflowResponse = 'Error while generating token, so unable to get messages. Check your debug log.';
            return;
        }
               
        try{
            HttpRequest objReq = new HttpRequest();
            objReq.setEndpoint('https://api-test.sovos.com/v1/workflow?countryCodes=ES&lastUpdatedAfter=01-01-2017');
            objReq.setMethod('GET');
            objReq.setHeader('Authorization', 'Bearer ' + generatedToken);
            Http objHttp = new Http();
            HTTPResponse objRes = objHttp.send(objReq);
            workflowResponse = objRes.getBody();
            if(String.isBlank(workflowResponse)){
                workflowResponse = objRes.toString();
            }
                       
            System.debug('workflowresponse :'+ workflowResponse);
            
            // JSON Parsing Logic
    
           JSON2Apex class1 = JSON2Apex.parse(workflowResponse);
         
            System.debug('class1 :'+ class1);            
           integer test =  class1.status;
                        
           List<JSON2Apex.Filings> filingslist = class1.data.filings;
            
            
            System.debug('filingslist :'  + filingslist);
            
            
            List<SOVOSAPIWorkflow__c> SAPIS = new list<SOVOSAPIWorkflow__c>();
            
            for(JSON2Apex.Filings eachfiling : filingslist){ 
                
                SOVOSAPIWorkflow__c SAPI = new SOVOSAPIWorkflow__c();
                
                SAPI.WorkFlow_Step__c    = eachfiling.workflowStep;
                SAPI.referenceId__c      = eachfiling.referenceId;
                SAPI.Company_Name__c     = eachfiling.companyName;
                SAPI.Due_Date__c         = date.valueOf(eachfiling.dueDate);
                
                
                string abc = eachfiling.title;
                
                System.debug('eachfiling :'  + eachfiling );
                System.debug('eachfiling company name :'  + eachfiling.companyName );
                
                SAPIS.add(SAPI);                   
             }
            
            insert SAPIS;
                                      
           System.debug('filingslist :'  + filingslist);
                                
         }
         catch(Exception ex)
         {  errorMessage = ex.getMessage();
            System.debug('Exception :' + ex.getMessage());
         }
                
    }  
 }



I can select it in the process :

User-added image

But when the process fires nothing happens. When I call the method from dev console/execute anonymous as sovosapi.getworkflow(); then it works and the records are inserted. 

Any ideas ? 

Thanks 

 
When creating the sales dashboard I can see from other threads people have changed the label of "Record Count" to "Number of Deals" - How do you do this ?  thanks 
 
My Trailhead profile page says 2 completed but IF I got the the main trails page I can see Ive got 4 marked as complete? Am I misunderstanding  something?  
Hi 

Trailhead just hanging when I press check answers ? Logged into dev org but hanging even on quiz answer type sections ? Any Ideas ? 

Thanks 

Andrew
 
On this Challenge under Advanced Formulas : 

Your company sells cylindrical hyperbaric chambers. You need a formula field that calculates the volume of a cylinder for you, rounded to the nearest whole number, given its radius and height. Use the existing mathematical formula for the volume of a cylinder, V = πr2h, where r is the radius of the cylinder, h is the height, and π is the constant Pi. Note: Although this formula field might best be created on a custom object, for simplicity, we’ll create this formula on the Opportunity object.

I get an error  about Discount_Percent__c being a missing field. This feild doesnt appear to have anything to do with the challenge ?? Confused.

Thanks 

Andrew
Hi 

Trailhead just hanging when I press check answers ? Logged into dev org but hanging even on quiz answer type sections ? Any Ideas ? 

Thanks 

Andrew
 
My Trailhead profile page says 2 completed but IF I got the the main trails page I can see Ive got 4 marked as complete? Am I misunderstanding  something?