• sasham
  • NEWBIE
  • 30 Points
  • Member since 2016

  • Chatter
    Feed
  • 0
    Best Answers
  • 1
    Likes Received
  • 0
    Likes Given
  • 24
    Questions
  • 31
    Replies
It is in Curl for makign Api calout for post method 

curl -H 'Accept: application/xml' -H 'Content-Type:application/xml' \
-u api_key:api_token -d '<message><data><result>
<id>123</id>
<address>cc</address>
<value>5</value>
</result></data></hl7message>'\
'https://example.com/customers/2342/messages

But How do make callout in Apex calss forthe above 
Specially for authentication  -u api_key:api_token
I have api key and token 
  • January 17, 2018
  • Like
  • 0
our client is supposed to send us notification after the resuts has been reviewd. 
1) approval notification 
2)Results  are  availble
these are the urls they asked me to  set up in our end 
http://example.com/notif?id={id}&status=approved
http://example.com/notif?id={id}&status=resulted[&result_type={result}]

For that . I need to setup up an apex class as a REST endpoint for an HTTP GET request that an external system is sending notification.
Please le me know is the right way do or please guide me 
@RestResource(urlMapping='/sample/approvalnotifications')
global without sharing class  Rest_Approval_Notification {

    
    @HttpGet
    global static void doGet() {
        
        System.debug(RestContext.request.requestBody);
        restresponse res=restcontext.response;
        String notification_id = RestContext.request.params.get('id');
        String notification_status = RestContext.request.params.get('status');
        System.debug(notification_id);
        System.debug(notification_status);
		
		//hadling error code and logic for processing 
        
        
        
    }
        
}

 


 
  • January 12, 2018
  • Like
  • 0
I have set up 2  apex class as a REST endpoint for an HTTP GET request that an external system is sending for 2 notification 
such as approved  and result available
http://example.com/notif?id={id}&status=approved
 http://example.com/notif?id={id}&status=resulted[&result_type={result}]
for authentication , we have 3 options 
IP Based Authentication
Token Based Authentication
HTTP Basic Authentication.
Could please  anyone answer , is Token Based Authentication is OAuth  authetication  and how to setup the Token Based Authentication
  • January 11, 2018
  • Like
  • 0
Could you pls some let me know the futue method can be used inside scheduer for long running process 
  • December 18, 2017
  • Like
  • 0
i need to  select  two dates from visualforce page (calender )  after cliciking on the button , in apex controller i need to use those two dates for createddate in the quer
for example if i select 1/20/2017 and 2/20/207  as dates in my page , the query need to retrive data between those two dates in apex controller 
  • December 12, 2017
  • Like
  • 0
how batch apex will handle this situation. we have more than 2000 paticipants in participant objects and steps and weight object
we need a job to handle everyday to find the highst step amonght participant for ranking and to find most hightest step for participant for specific period of time.
if i set chuck to 1 . how all all the particpant steps can be compared.
 
  • December 07, 2017
  • Like
  • 0
Hi 
I have scheduled scheduler class everyday at 1pm(through UI). It seems to be woeking in my staging sanbox. but when i see in the apex job . it is status as queued  and  it should have one staus at 1pm as completed if it was woring at 1 pm.  but as queued.
but i production i can see the status as failed and  staus detail as Scheduler: failed to execute scheduled job: jobId:456778999X class: common.apex.async.AsyncApexJobObject, reason: Apex CPU time limit exceeded.
My question  is It failed in production because cpu time exceeded but in staging why there isno staus as completed or failed but looks like it is working.

 
  • December 03, 2017
  • Like
  • 0
Hi 

We have custom Participant object and custom timezone field(pick list - cetral , eastern arizona and pacific ). for each particiipat , particiipant address (state and zip code) is stored in child object called participantdetail. 
when new participnat is created , how do i populate the time zone  field with thier timezone ( i have  the zip code in address  and is it possible to populate the timezone field using the zip code  ) or any other way.  . 
  • November 14, 2017
  • Like
  • 0
It works in prodction but not in sanbox (acsess token is not required)
  • November 08, 2017
  • Like
  • 0
How do i access Api (public rest api , no need acsess token ) form postmen or runscope. but i woks in workbench 
It showing an error  invalid session id . It works in production not in sanbox 
  • November 07, 2017
  • Like
  • 1
I have craeted custom Rest Api (post method and get ) . Pls let me know if that Api can be called from marketting cloud and how (using java script)
  • November 01, 2017
  • Like
  • 0
  • October 31, 2017
  • Like
  • 0
 I have some questions and clarification. This code is used using Vf page and button . when i click on the button it will update the states We have huge participants in the system . i am querying all the participants , states and Reviews in my code. pls let me know it will not throw an error in regards to governor limit if that so , how do i change and what to do for that ( i used map for that ) still confusing Pls answer if it is possible
public PageReference insertstates(

String statesRec = assessed;
String quiz= '123'
PsRecsById = new Map<id, States__c>();
recsById =  new Map<id, (participant__c> ();
         for(States__c st : [select Id,participant__c,state_c
                                         from  States__c
                                           where participant__c!=null and State__c=:statesRec])
             {
                PsRecsById .put(st.participant__c, st);
                 
             }
         stateIds = new Set<ID>();
         stateIds= PsRecsById .keyset();
         
        
         reviewtRecsById.put= new Map<Decimal, Review_C>(); 
         for(Review_C  assrecs : [select Id, RL_C,Quiz_C,CreatedDate from  Review_C where  Quiz_C=:quiz])
             {
                reviewtRecsById.put((Decimal)assrecs.RL_C, assrecs);
                 
             } 
         
          List<States__c> insertList = new List <States__c>();
         
         for(participant__c par :[select id,RL_C from participant__c where RL_C =:reviewtRecsById.keySet()])
             {
               // recsById.put(par.id, par);
                if(!stateIds.contains(par.ID))
                {
                     States__c stateObj = new States__c();
                     stateObj.participant__c = par.Id;
                     stateObj.State__c =statesRec.id;                  
                     stateObj.ReceivedAt_C=reviewRecsById.get(par.RL_C ).CreatedDate;
                     insertList.add(stateObj);
                }
             }
         if(insertList.size()>0)
         {
             insert insertList;
         }
      
return null; 
}

 
  • October 25, 2017
  • Like
  • 0
two objects - participant and State
Participant  -  Participantt_c 
State - Participantt_c (look up field), states( picklist as egistered and assesesd)
queriyng all participants whch match the id  from  other object (assesment)  and get craeted date form assesment
and then  see if there is  a state  as assesed for ecah participant from state table using those ids  , if not need to insert one 
I am trying to use the map to get participant id which match from assesment object and get the craeted date from assesment 
I m confusing using map 
  • October 23, 2017
  • Like
  • 0
I have all participant and states object (two records registered and assessed ). for some participant is not assesed inthe table evethough it is actually assessed. need to insert those records to states as assesesd 

i have list of patticipant ids and list of  states as assessed 

 if(recs.size()>0 && participantsatates.size()>0) 
         {
              for(participant__c p:recs)
                 {
             
                     for(States__c pstate :participantsatates)
                         
                         {
                            IF (P.Id = pstate.Participant__c)
                            {
                                
                                
                            }
                             
                 
                         }
                 }
  • October 23, 2017
  • Like
  • 0
Please anyone explain if you are using SAST tool for security code review..(Security testing)
How do  i make sure my code for the sast tool result will be positive. 
what are thing i need to consider when i i do coding 
  • October 20, 2017
  • Like
  • 0
Could you pls someone explain how to debug wat is the satus of the trigger and monitoe if it is not working in mainly prodction 
For example: Reason : i have trigger(after trigger)  on one objects registarion . it is inserting date into an other object(states) . after registarion is created , it is inserting record in to states


 
  • October 18, 2017
  • Like
  • 0
Could ypu pls someone explain 
How to determine for tye first time login thorough moble  salesforce app which is developeed usiing mobile sdk native app (from ios or android).  Is there any field that we can identify if user (customers)logged in for the first time even if they are changing device or deleting the app and downloading again on their device.
  • September 19, 2017
  • Like
  • 0
custom rest api issues with response
I am having issues with one of the api  (custom rest)whcih is called(from the moble  app) to retrive some customer data to show in the mobile . sometimes I amm getting error messgaes  System.JasonException :can not start an object expecting field name\n\nClass.System.JasonGenerator.writeStartobject: line. Sometimes i am getting response without any code chanes .. we are having issues customers couldnt see thier data in mobile  app
could you pls someone explain  why this  is happening
  • September 19, 2017
  • Like
  • 0
Test method  for Scheduler Apex code  shows this exception in procution  when we are validatiing other code.
Pls anyone help how to solve in prodcution 
Is there anyway to handle in test method
  • August 21, 2017
  • Like
  • 0
How do i access Api (public rest api , no need acsess token ) form postmen or runscope. but i woks in workbench 
It showing an error  invalid session id . It works in production not in sanbox 
  • November 07, 2017
  • Like
  • 1
our client is supposed to send us notification after the resuts has been reviewd. 
1) approval notification 
2)Results  are  availble
these are the urls they asked me to  set up in our end 
http://example.com/notif?id={id}&status=approved
http://example.com/notif?id={id}&status=resulted[&result_type={result}]

For that . I need to setup up an apex class as a REST endpoint for an HTTP GET request that an external system is sending notification.
Please le me know is the right way do or please guide me 
@RestResource(urlMapping='/sample/approvalnotifications')
global without sharing class  Rest_Approval_Notification {

    
    @HttpGet
    global static void doGet() {
        
        System.debug(RestContext.request.requestBody);
        restresponse res=restcontext.response;
        String notification_id = RestContext.request.params.get('id');
        String notification_status = RestContext.request.params.get('status');
        System.debug(notification_id);
        System.debug(notification_status);
		
		//hadling error code and logic for processing 
        
        
        
    }
        
}

 


 
  • January 12, 2018
  • Like
  • 0
how batch apex will handle this situation. we have more than 2000 paticipants in participant objects and steps and weight object
we need a job to handle everyday to find the highst step amonght participant for ranking and to find most hightest step for participant for specific period of time.
if i set chuck to 1 . how all all the particpant steps can be compared.
 
  • December 07, 2017
  • Like
  • 0
Hi 

We have custom Participant object and custom timezone field(pick list - cetral , eastern arizona and pacific ). for each particiipat , particiipant address (state and zip code) is stored in child object called participantdetail. 
when new participnat is created , how do i populate the time zone  field with thier timezone ( i have  the zip code in address  and is it possible to populate the timezone field using the zip code  ) or any other way.  . 
  • November 14, 2017
  • Like
  • 0
It works in prodction but not in sanbox (acsess token is not required)
  • November 08, 2017
  • Like
  • 0
How do i access Api (public rest api , no need acsess token ) form postmen or runscope. but i woks in workbench 
It showing an error  invalid session id . It works in production not in sanbox 
  • November 07, 2017
  • Like
  • 1
I have all participant and states object (two records registered and assessed ). for some participant is not assesed inthe table evethough it is actually assessed. need to insert those records to states as assesesd 

i have list of patticipant ids and list of  states as assessed 

 if(recs.size()>0 && participantsatates.size()>0) 
         {
              for(participant__c p:recs)
                 {
             
                     for(States__c pstate :participantsatates)
                         
                         {
                            IF (P.Id = pstate.Participant__c)
                            {
                                
                                
                            }
                             
                 
                         }
                 }
  • October 23, 2017
  • Like
  • 0
Could ypu pls someone explain 
How to determine for tye first time login thorough moble  salesforce app which is developeed usiing mobile sdk native app (from ios or android).  Is there any field that we can identify if user (customers)logged in for the first time even if they are changing device or deleting the app and downloading again on their device.
  • September 19, 2017
  • Like
  • 0
Test method  for Scheduler Apex code  shows this exception in procution  when we are validatiing other code.
Pls anyone help how to solve in prodcution 
Is there anyway to handle in test method
  • August 21, 2017
  • Like
  • 0
I craeted custom button on  participant table and link Vf pageto the button . when i clicked on the button , address table will get updated 
This is my controller extension  and Vf page .i need help on the test calss 
public with sharing class PClass{

    public participant__c participant;
    private ApexPages.StandardController stdControler;
    public Id Id { get; set; }
    
    
    public PClass(ApexPages.StandardController stdControler){
        
        this.participant = (participant__c)stdControler.getRecord();
        this.stdControler = stdControler;
            
    }
    
    public PageReference InsertAddress(){
        	
        try{
            participant__c p = [select id, SS_ID__c 
                                from participant__c
                               where Id = :participant.Id limit 1];
                             
           Registration__c r= [select Id,Address1__c, Address2__c,SS_ID__c 
                                                                        from Registration__c 
                                                                        where SS_ID__c =:p.SS_ID__c limit 1];
                                                                        
            Addresses_c  paddress = new Addresses__c();
            paddress.participant__c = participant.Id;
            paddress.Address1__c = r.Address1__c;
            paddress.Address2__c = r.Address2__c;
            insert paddress;
	   }

	   catch (Exception e){}
           return new ApexPages.StandardController(participant).view();
}
VF page 
<apex:page standardController="Participant__c" extensions="PClass" action="{!InsertAddress}" >


</apex:page>
My test class
@isTest public  with sharing class PClass_Test {

    static TestMethod void AddAddress(){
        
        
        Registration__c  TestRegistration= new Registration__c();
        TestRegistration.Name = 'Test Registration';
        TestRegistration.SS_ID__c = Decimal.valueOf(30111);
        TestRegistration.Address1__c='10 Street';
        TestRegistration.Address2__c ='15 street';
        insert TestRegistration;
        
        participant__c TestParticipant = new participant__c();
        TestParticipant.FirstName__c ='Test participant';
        TestParticipant.SS_ID__c =Decimal.valueOf(30111);;
        insert TestParticipant;
        
	Test.startTest();
        ApexPages.StandardController stdController = new ApexPages.StandardController(TestParticipant);
        PClass  pa = new PClass(stdController);
       System.debug(pa.Id);
      
        
       	pa.InsertAddress();
        System.debug(pa);
        
        Test.stopTest();
        try{
        
     		Addresses_c padd = [select id, participant__c from Addresses_c where participant__c =:pa.Id limit 1];
           }
      catch (Exception e){}
}


 
  • August 15, 2017
  • Like
  • 0
It is  a Apex code 
My pick list value  for TimeFrame __c  is  12:00 - 08:00 AM.  
I  need to insert into string  starttime__c  as 12 Am and  endTime__C as  8 AM from that value that i m getting ffor TimeFrame __c
  • August 14, 2017
  • Like
  • 0