• AkashGarg555
  • NEWBIE
  • 15 Points
  • Member since 2019
  • Salesforce Administrator & Developer

  • Chatter
    Feed
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 3
    Questions
  • 8
    Replies
Hi,
I have a requirement where I have to put a ID in "inputtext" and after clicking on button, i have to show the result in table .
I am very badly stuck in this.
Controller : -
public with sharing class HealthCheckRestCallsUtility {

    @RemoteAction
    public static List<Request360Controller.MultipleRequestDetail> fetchRequestsStatus(String requestIds) {
        

        return  Request360Controller.getRequestDetails(requestIds);

    }
}
 
VF Page : - 

<apex:page controller="HealthCheckRestCallsUtility">
    <script>
     function passingValue(){
         var primeProductId=document.getElementById("j_id0:j_id2:j_id3:txt1").value;
         send(primeProductId);
    }
    </script>
    <apex:form >
        <apex:pageBlock title="Check Request Status">
            <apex:inputText value="{!inputTxt1}" id="txt1" />
            <br/>
            <apex:commandButton value="Check Status" onclick="passingValue()">
                <apex:param name="primeProductId" AssignTo="{!primeProductId}" />
            </apex:commandButton> 
            <apex:actionFunction name="send" action="{!fetchRequestsStatus()}">
                <apex:param name="primeProductId" AssignTo="{!primeProductId}" />
        	</apex:actionFunction> 
        </apex:pageBlock>   
    </apex:form>
</apex:page
I have a requirement where CustomerSuccess__c field on opportunity to be updated  'true' if CustomerSuccess__c field on Account is 'true' in before Insert event.

I have tried below solution, trigger saved succesfully but it didn't work.
Can anyone explain why my trigger is not working
trigger OppoCustomerSuccessCheckboxUpdate on Opportunity (before insert) 
{
for(Opportunity opp : Trigger.New)
{
	if(Opp.AccountID != null)
	{
		if(Opp.Account.CustomerSuccess__c)
		{
			Opp.CustomerSuccess__c = true;
		}
	}
}
}
Regards,
Akash
 
Hi,

I'm trying to fetch the data of one salesforce Org to another through HTTP request method.
I'm able to fetch the session ID but when i'm using this Session ID it give me error of "message":"INVALID_HEADER_TYPE","errorCode":"INVALID_AUTH_HEADER".
Can anyone help as this is very urgent.
 
public with sharing class AuthCallout 
{
    public static string getOrgSessionId(string orgICIXId)
    {
        HttpRequest req = new HttpRequest();         
        String content = UserInfo.getOrganizationId() + '.' + DateTime.now().formatGMT('yyyy-MM-dd\'T\'HH:mm:ss.S\'Z\'');
        String signature = EncodingUtil.base64Encode(Blob.valueOf(content)) + '.' + EncodingUtil.base64Encode(Crypto.generateMac('HmacSHA256', Blob.valueOf(content), Blob.valueOf( UserInfo.getOrganizationId() )));
        req.setEndpoint('https://staging-concateno.herokuapp.com/util/session-id/' + orgICIXId);
        req.setMethod('GET');
        req.setHeader('Authorization', signature);
        req.setHeader('Content-Type', 'application/json');
        
        Http http = new Http();
        HTTPResponse res = http.send(req);
        System.debug(res.getBody());
        return res.getBody();
    }
    public static string getData() {
        
        string orgSessionId = getOrgSessionId('304736');
        string workflowGlobalId = '304736';
        string queryToRun = 'SELECT Id, Name FROM BR1DevStgRes__Workflow_Instance__c WHERE BR1DevStgRes__Global_Id__c='+workflowGlobalId;
        system.debug('orgSessionId : '+orgSessionId);
        system.debug('queryToRun : '+queryToRun);
        HttpRequest req1 = new HttpRequest();
        req1.setEndpoint('https://na85.salesforce.com/services/data/v38.0/query/?q=' + EncodingUtil.urlEncode(queryToRun, 'utf-8') );
        req1.setMethod('GET');
        req1.setHeader('Authorization', 'OAuth '+orgSessionId);
        req1.setHeader('Content-Type', 'application/json');
        
        Http http1 = new Http();
        HTTPResponse res = http1.send(req1);
        System.debug(res.getBody()); 
        return res.getBody();
    }
}
Debug Log Error
 
I have a requirement where CustomerSuccess__c field on opportunity to be updated  'true' if CustomerSuccess__c field on Account is 'true' in before Insert event.

I have tried below solution, trigger saved succesfully but it didn't work.
Can anyone explain why my trigger is not working
trigger OppoCustomerSuccessCheckboxUpdate on Opportunity (before insert) 
{
for(Opportunity opp : Trigger.New)
{
	if(Opp.AccountID != null)
	{
		if(Opp.Account.CustomerSuccess__c)
		{
			Opp.CustomerSuccess__c = true;
		}
	}
}
}
Regards,
Akash
 
Hi Devi Chandrika,
   Now i am trying for another trailhead challenge and below is my problem statement and my code and error as well.Kindly suggest me.
The Apex class must be called ContactSearch and be in the public scope
The Apex class must have a public static method called searchForContacts
The method must accept two incoming strings as parameters
The method should then find any contact that has a last name matching the first string, and mailing postal code (API name: MailingPostalCode) matching the second string
The method should finally return a list of Contact records of type List that includes the ID and Name fields

My Code:
public class ContactSearch {
    public static contact[] searchForContacts(string lstName,string mpostalcode)
    {
        contact[] cts = [SELECT FirstName,LastName,ID
                          FROM Contact WHERE LastName=:lstName AND mailingpostalcode=:mpostalcode];
            
            return cts;
        
    }

}

I am getting the below error in trailhead challenge.
There was an unexpected error in your org which is preventing this assessment check from completing: System.DmlException: Insert failed. First exception on row 0; first error: REQUIRED_FIELD_MISSING, Required fields are missing: [Loan_Amount__c]: [Loan_Amount__c]

Kindly suggest me.

Regards,
Thangamani
Hi All, I need to write a trigger on Opportunity object for checkbox field update by checking the value of a field in Account Object, this trigger will be before insert.
if account.custonersuccess=TRUE then opportunity.customersuccessblock= TRUE