• Hardik Chavda
  • NEWBIE
  • 20 Points
  • Member since 2015

  • Chatter
    Feed
  • 0
    Best Answers
  • 1
    Likes Received
  • 0
    Likes Given
  • 9
    Questions
  • 7
    Replies

Hi,

I am actually new to REST api and tried one simple example by connecting 2 salesforce org. Following is the snippet of my code.

Source Org Class.

public class RestServiceCalloutController{
    
    public void CalloutRest(){
        try{
            HttpRequest req = new HttpRequest();
            req.setEndpoint('https://ap2.salesforce.com/services/apexrest/TestAccount');
            req.setMethod('POST');
            String authorizationHeader = 'Bearer '+SessionId; //put the sessionId manually from the destination org.
            req.setHeader('Authorization', authorizationHeader);
            //req.setHeader('Content-Type', 'application/json');
            system.debug('*******REQ'+req);
            
            Http http = new Http();
            HTTPResponse res = http.send(req);
            system.debug('*******Res'+res);
        }
        catch(exception e){
            system.debug('--------EXCEPTION-----'+e);
        }
    }
 
}
Destination Org Class.
 
@RestResource(urlMapping='/TestAccount/*')
global class TestRestApi{
    
        @HttpPost
        global static void TestRest(){
                system.debug('Caaling');
        }
}

When I call the code from the source org. It sends the request but in response it gives me back this error : System.HttpResponse[Status=Bad Request, StatusCode=400],

I even tried using SOAP UI, It shows me the following error. 

User-added image

I also went to critical updates and activate the TLS 1.1, Can anyone please help me with this?

Thanks in advance.
I'm working on one page and facing this error, "Subscript is invalid because list is empty", As I checked in google, but I didn't get satisfied answer and didn't resolve it yet. Can anyone explain me what this error is about and what are the scenarios that will occur?  I've to say that there is lots of usage of javascripts and CSS in my page. I'm looking forward for reply. TIA. 
 
str = new list<String>();      
setOfCustomerIssue = new set<String>();
                
if(Que.Customer_Issues__c != null){
CustomerIssue = Que.Customer_Issues__c;
                    
for(String s : CustomerIssue.split(';')){
Str.add(s);
setOfCustomerIssue.add(s);
}
}
Below is my class code.
 
<li>
<apex:variable var="i" value="{!0}"/>
<apex:repeat value="{!AssWrapperList[CurrentPos].str}" var="item">  
<span style="color: #667B8D;font-weight: 700;">{!item}</span><br/>
<apex:variable var="i" value="{!i+1}"/>
</apex:repeat>
</li>
Below is page code. And I'm facing error like "error is in expression
{!AssWrapperList[CurrentPos].str}
". Can anyone help me with this?
 
<apex:actionFunction action="{!testMethod}" name="testFunction" oncomplete="{!if(var == true),onPageRerender();,endProcess();}" reRender="testId"/>
below is my action function in which I want to call multiple js function according to boolean variable which is in the controller. Is it possible? because it's not working, Can anyone help with this?
I've one requirement in which I have to split a string in visualforce page. Following is what I need.
I'm using one datatable in page. which contains one field of string data type. based on that field I want to show another field. Following is what I tried.
<apex:dataTable value="{!QATlst}" var="Ass">

                           <apex:variable var="name" value="{!Ass.Benchmark_Name__c}"/>

                                    <apex:column style="text-align: left;" width="45%">
                    
                                            <apex:facet name="header">Metric Name</apex:facet>
                    
                                            <apex:outputText styleClass="colData" value="{!Ass.Benchmark_Name__c}" style="font-size:14px"/>
                                      
                    
                                    </apex:column>
                                    <apex:column style="text-align:center;" width="5%">
                    
                                            <apex:facet name="header" >Industry Benchmark </apex:facet>
                    
                                            <apex:outputText styleClass="colData" value="{0, number, 0.00}" style="font-size:14px">
                                                <apex:param value="(!if(Contains(name,'Average')),{!Ass.Average_median_value__c},{!Ass.Customer_input_Transformed_value__c})" />
                                            </apex:outputText>
                    
</apex:column>
                                    
</apex:dataTable>
So here, If the field record contains "Average" then It'll show other field and if it doesn't contain "Average" then it'll show another field. Anyone can help me with this??
Following is my code.
Commandlink is not working like this,Can anyone help me on this??
<apex:outputpanel id="filterpanel">
<apex:outputpanel id="filterpanel1" rendered="{!NOT(issummary)}">
<div class="col-xs-2" id="panel1">
<apex:commandLink id="test1" reRender="level2list,theRepeat" onclick="chngecolor();"  >
               <div class="panel panel-green">
                                    <div class="panel-heading">                                    
                                        <div class="row" style="height: 30px;">
                                            <div id="headingText" style="width: 66.66666667%; float:right;  font-size: 18px;" >
                                              Cost                                     
                                            </div>
                                        </div>
                                     
                                    </div>
                                </div>
 </apex:commandlink>
</apex:outputpanel>
</apex:outputpanel>
Hi,
I have to call javascript functions oncomplete method but using if condition. Actually I can call using if condition but the issue which I'm facing is that I am not able to use controller variable for coparision in if codition. Can anyone help me with this? Following is the code.
<apex:commandButton styleClass="btn btn-primary" action="{!NextAssessment}" value="Next " oncomplete="if(!currentPos == totalQuestion){return;}else{onPageRerender();endProcess();}" onclick="startProcess();" reRender="AssessmentBody,op1,op2" />
The issue here is that in oncomplete method, I'm not able to compare those two controller variable, I guess It's not getting value from controller. Can anyone suggest me right syntex how to use "if(!currentPos == totalQuestion)" ?

"CurrentPos" and "totalQuestion" both are controller variable.
Hi,
I have to call javascript function at the time of page loading. Following is my code and explaination of what I want to achieve.
<apex:page sidebar="false" controller="someController" >

<script>
function callThisFunctionAtThePageLoad(/*parameter will be passed from controller*/){
//alert('show this alert');
}
</script>

</apex:page>
So here, I want to pass one parameter in function for condition checking, which will come from the controller.
Following is my code.
<apex:actionFunction action="{!BusinessPartnering}" name="BusinessPartnering" oncomplete="onPageRerender();endProcess();ChangeBackgroundColor(//pass the value of <apex:param>');" reRender="AssessmentBody">
            <apex:param name="firstParam" assignTo="{!FunctionalAreaParam}" value="" />
        </apex:actionFunction>

Now here, I want to pass the <apex:param> value as a argument in ChangeBackgroundcolor() method. Can anyone help me with this?
Hi,
I have to call javascript function at the time of page loading. Following is my code and explaination of what I want to achieve.
<apex:page sidebar="false" controller="someController" >

<script>
function callThisFunctionAtThePageLoad(/*parameter will be passed from controller*/){
//alert('show this alert');
}
</script>

</apex:page>
So here, I want to pass one parameter in function for condition checking, which will come from the controller.
<apex:actionFunction action="{!testMethod}" name="testFunction" oncomplete="{!if(var == true),onPageRerender();,endProcess();}" reRender="testId"/>
below is my action function in which I want to call multiple js function according to boolean variable which is in the controller. Is it possible? because it's not working, Can anyone help with this?
Hi,
I have to call javascript function at the time of page loading. Following is my code and explaination of what I want to achieve.
<apex:page sidebar="false" controller="someController" >

<script>
function callThisFunctionAtThePageLoad(/*parameter will be passed from controller*/){
//alert('show this alert');
}
</script>

</apex:page>
So here, I want to pass one parameter in function for condition checking, which will come from the controller.
Following is my code.
<apex:actionFunction action="{!BusinessPartnering}" name="BusinessPartnering" oncomplete="onPageRerender();endProcess();ChangeBackgroundColor(//pass the value of <apex:param>');" reRender="AssessmentBody">
            <apex:param name="firstParam" assignTo="{!FunctionalAreaParam}" value="" />
        </apex:actionFunction>

Now here, I want to pass the <apex:param> value as a argument in ChangeBackgroundcolor() method. Can anyone help me with this?
Hi All,

I am using opportunity object and order object(custom object) which is the child of Opportunity. If one user with one profile is uploading an attachment in order object, another user with another profile is not able to see the attachments. I have made the private value of attachment as false only. I don't want to give View All Data permission to the users. Is there any other way to make the attachments visible to other users. Please help.

Thanks
String query = 'SELECT Id, Name, Contract__r.Account.Name AccountName, Contract__r.Account.Industry Industry, Contract__r.Account.Sub_Industry__c SubIndustry, Contract__r.Account.Account_Owner_Alias__c AccountOwner, Contract__r.ContractNumber ContractNumber, Contract__r.Account.Owner.FirstName OwnerFirstName, Contract__r.Account.Owner.LastName OwnerLastName,Contact__r.FirstName ContactFirstName, Contact__r.LastName ContactLastName, Contract__r.Account.CSM__c CSMId, Contract__r.Account.CSM__r.FirstName CSMFirstName, Contract__r.Account.CSM__r.LastName CSMLastName,Product__r.Research_Area__c ResearchArea,Product_Code__c ProductCode,Contract__c ContractId,Contact__c ContactId,Contact__r.Title_Level__c TitleLevel,Status__c,Contract__r.AccountId AccountId,Product_Family__c ProductFamily FROM Contract_User__c  LIMIT 200';
        return Database.getQueryLocator(query);