• agarcia
  • NEWBIE
  • 0 Points
  • Member since 2010

  • Chatter
    Feed
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 4
    Questions
  • 5
    Replies
I have an Apex class sending http requests to an enpoint.  I then have a calss that schedules to query an object and send records that match.  The issue now is, I need to control how many this sends.  Basically I need to say:

If records match this criteria, send 100 of them.  Or 500 of them.  

Any idea on how I can accomplish this?  I have thought about trying to use WFR to add numbers to a field and then part of the criteria would be "if The_custom_field__c = 1-100" then fire a trigger to clear those numbers.  This just seems very messy and I am sure there is a cleaner way.  Any thoughts?  
I have an Flow which sends a POST to an external System.  Is there a way to either display the response in the Flow, or write it to a variable which would update a field on an object?

 
I am trying to write a test class for the code below.  Can anyone help??  The (List<String> SubmitData) passes json formatted string which comes from a flow(example below).  


public class ASGITS {
@InvocableMethod(label='Send ASG-ITS')
    public static void sendASGITS (List<String> SubmitData){
        
        Http http = new Http();
        HttpRequest req = new HttpRequest();
        String payload = SubmitData.get(0);
        req.setEndpoint('https://secure.sample.com/test/manage.svc/PostNewExam');
        req.setMethod('POST');
        req.setHeader('Content-Type', 'application/json');
        req.setBody(payload);  
        HttpResponse res = http.send(req);
if (res.getStatusCode() != 200) {
    System.debug('The status code returned was not expected: ' +
        res.getStatusCode() + ' ' + res.getStatus());
} else {
    System.debug(res.getBody());
}               
}
}



Sample Code the flow is passing to the variable "SubmitData"
{"ExamType":"ORTHOTICS","PatientFirstName":"{!First_Name}","PatientLastName":"{!Last_Name}","PatientDob":"{!Date_of_Birth}","PatientSex":"{!M_F_Convert}","PatientHomePhone":"{!Phone}","PatientAddress1":"{!Street}","PatientCity":"{!City}","PatientState":"{!State}","PatientPostalCode":"{!Zip_Code}"}
 
I have a vendor that wants to send new records to our existing RestResource via URL parameters (...abc.com?Name=Sample&Phone=8135551212).  How can I accept this?  I have been looking into JSON.deserializeuntyped(req.requestbody.tostring() but I just cant get anything to work. 
As a side note, my RestResource is exposed publicly via site.com with permissions to POST only.  
Here is a sample of what my code currently looks like.  


@RestResource(urlMapping='/abc/*')

global with sharing class sample {
    @HttpPost
    global static Map <String,String> createrecord (String Name,  
                                                    String Phone) {
      
        Map <String, String> s = new Map <String, String>();
        
        record r = new record(
            Name__c = Name,
            Phone__c = Phone);

        Database.SaveResult db = Database.insert(r, false);
        if(db.isSuccess()){
            s.put('isSuccess','True');
            s.put('status','Success');
            s.put ('RecordId',r.Id);
        }
        else{
            s.put('isSuccess','False');
            s.put('status','failure');
            s.put('message','Error');
            s.put('errorCode','Not Found');
            List <Database.Error> errors = db.getErrors();
            for(Database.Error error : errors){
                s.put('error', error.getMessage());
            }
        }
        return s;
    }
}
I am trying to write a test class for the code below.  Can anyone help??  The (List<String> SubmitData) passes json formatted string which comes from a flow(example below).  


public class ASGITS {
@InvocableMethod(label='Send ASG-ITS')
    public static void sendASGITS (List<String> SubmitData){
        
        Http http = new Http();
        HttpRequest req = new HttpRequest();
        String payload = SubmitData.get(0);
        req.setEndpoint('https://secure.sample.com/test/manage.svc/PostNewExam');
        req.setMethod('POST');
        req.setHeader('Content-Type', 'application/json');
        req.setBody(payload);  
        HttpResponse res = http.send(req);
if (res.getStatusCode() != 200) {
    System.debug('The status code returned was not expected: ' +
        res.getStatusCode() + ' ' + res.getStatus());
} else {
    System.debug(res.getBody());
}               
}
}



Sample Code the flow is passing to the variable "SubmitData"
{"ExamType":"ORTHOTICS","PatientFirstName":"{!First_Name}","PatientLastName":"{!Last_Name}","PatientDob":"{!Date_of_Birth}","PatientSex":"{!M_F_Convert}","PatientHomePhone":"{!Phone}","PatientAddress1":"{!Street}","PatientCity":"{!City}","PatientState":"{!State}","PatientPostalCode":"{!Zip_Code}"}
 
I have a vendor that wants to send new records to our existing RestResource via URL parameters (...abc.com?Name=Sample&Phone=8135551212).  How can I accept this?  I have been looking into JSON.deserializeuntyped(req.requestbody.tostring() but I just cant get anything to work. 
As a side note, my RestResource is exposed publicly via site.com with permissions to POST only.  
Here is a sample of what my code currently looks like.  


@RestResource(urlMapping='/abc/*')

global with sharing class sample {
    @HttpPost
    global static Map <String,String> createrecord (String Name,  
                                                    String Phone) {
      
        Map <String, String> s = new Map <String, String>();
        
        record r = new record(
            Name__c = Name,
            Phone__c = Phone);

        Database.SaveResult db = Database.insert(r, false);
        if(db.isSuccess()){
            s.put('isSuccess','True');
            s.put('status','Success');
            s.put ('RecordId',r.Id);
        }
        else{
            s.put('isSuccess','False');
            s.put('status','failure');
            s.put('message','Error');
            s.put('errorCode','Not Found');
            List <Database.Error> errors = db.getErrors();
            for(Database.Error error : errors){
                s.put('error', error.getMessage());
            }
        }
        return s;
    }
}

Hi, For opportunity we have OpportunityHistory object to track some fields in opportunity. same as Lead(LeadHistory), case(caseHistory).. But we dont have Task history object for Task..So Please tel me how to track fields in task object....

If any idea would appreciate...

Hi,

 

We are a mid-size, media arts non-profit and a Mac house. We want to begin barcoding our equipment and managing/tracking the equipment in S/F. Does anyone have any experience using the resource management feature along with barcodes. 

 

Specifically, we are interested in barcoding equipment with pre-made bar codes and then using a basic bar-code scanner to scan the item in and out of S/F. 

 

I know there are enterprise warehouse management tools out there, but we need something way less complicated for simple tracking. Thanks!!!

  • September 30, 2009
  • Like
  • 0