• Bobby Knezevic
  • NEWBIE
  • 10 Points
  • Member since 2015

  • Chatter
    Feed
  • 0
    Best Answers
  • 8
    Likes Received
  • 0
    Likes Given
  • 4
    Questions
  • 7
    Replies
I'm struggling to understand what kind of restrictions are in place when making a HTTP request to a Salesforce resource within a custom REST endpoint. When I construct the request in a console as such ...
HttpRequest request = new HttpRequest();
request.setEndpoint('https://<my hostname>/apex/MyVisualforcePage');
request.setMethod('GET');
request.setHeader('Authorization', 'Bearer ' + UserInfo.getSessionId());
request.setBody('param1=foo&param2=bar');

HttpResponse response = new Http().send(request);
System.debug(response.getBody());
... I get the page content in HTML correctly.

However, when I make the same call in a custom REST endpoint I get the following output:
\r\n<!DOCTYPE HTML PUBLIC \"-//W3C//DTD HTML 4.01 Transitional//EN\" \"http://www.w3.org/TR/html4/loose.dtd\">\n<html>\n<head>\n    <meta HTTP-EQUIV=\"PRAGMA\" CONTENT=\"NO-CACHE\">\n\n\n\n\n\n<script>\nif (this.SfdcApp && this.SfdcApp.projectOneNavigator) { SfdcApp.projectOneNavigator.handleRedirect('https://evestment--dev.cs13.my.salesforce.com?ec=302&startURL=%2Fapex%2FInvoiceNotificationEmail'); }  else \nif (window.location.replace){ \nwindow.location.replace('https://evestment--dev.cs13.my.salesforce.com?ec=302&startURL=%2Fapex%2FInvoiceNotificationEmail');\n} else {;\nwindow.location.href ='https://evestment--dev.cs13.my.salesforce.com?ec=302&startURL=%2Fapex%2FInvoiceNotificationEmail';\n} \n</script>\n\n</head>\n\n\n</html>\n\n\n\n\n\n<!-- Body events -->\n<script type=\"text/javascript\">function bodyOnLoad(){if(window.PreferenceBits){window.PreferenceBits.prototype.csrfToken=\"null\";};}function bodyOnBeforeUnload(){}function bodyOnFocus(){}function bodyOnUnload(){}</script>\n\t\t\t\n</body>\n</html>\n\n\n<!--\n...................................................................................................\n...................................................................................................\n...................................................................................................\n...................................................................................................\n-->\n\n\n

The response appears to be a page that is redirecting to a login page, but I could be wrong. I'm making the call to the custom REST endpoint via Postman when I received the undesirable output above. I've tried obtaining a session id via Postman and using the same session id in the call to the REST endpoint AND the call to the Salesforce resource (i.e. replacing UserInfo.getSessionId() with the session id). The user authenticating is a sys admin and is the same user running the anonymous code in the console for the positive test.

Can anyone shed any light on why this might be happening?
I have a very simple <ui:inputSelectOption> element and a button that calls a controller action that examines the element's label and value. However, the label is "undefined" on the select element.
 
<ui:inputSelect aura:id="pricebooks">
    <ui:inputSelectOption text="" label="--None--" />
    <aura:iteration items="{!v.pricebooks}" var="pricebook">
        <ui:inputSelectOption text="{!pricebook.Id}" label="{!pricebook.Name}" />
    </aura:iteration>
</ui:inputSelect>

<button onclick="{!c.selectPricebook}">Select</button>

Controller code:
({
    selectPricebook: function(component, event, helper) {
        var selectCmp = component.find("pricebooks");
	var value = selectCmp.get("v.value");
        console.log(value); // The expected result
        var label = selectCmp.get("v.label");
        console.log(label); // undefined
})

I've examined the selectCmp object in the debugger and the label property is, in fact, "undefined". What could be the problem here?
Hello, there. I'm working on very first Lightning application, and I'm noticing some strange behavior. I'm using a VF page with <apex:includeLightning /> and a script to load a component from an app like so:
 
$Lightning.use("c:OpportunityProductApp", function() {
    $Lightning.createComponent("c:PricebookSelector", {}, "pricebookSelector", function(cmp) {
        console.log('loaded component ...');
	    // do some stuff here
    });
});
The Lightning application is very simple:
 
<aura:application access="GLOBAL" extends="ltng:outApp">
    <c:PricebookSelector />
</aura:application>
The lightning component is as equally simple:
<aura:component controller="PricebookSelectorController">
    <aura:attribute name="pricebooks" type="List" />
    <aura:handler name="init" value="{!this}" action="{!c.doInit}" />
</aura:component>
The component controller looks like this:
({
    doInit : function(component, event, helper) {
        helper.getPricebooks(component);
    }
})
Finally, the component helper looks like this:
({
    getPricebooks: function(component) {
        var action = component.get("c.getPricebooks");

	    var self = this;
	    action.setCallback(this, function(actionResult) {
		    console.log(actionResult);
	    });

	    $A.enqueueAction(action);
    }
})
The problem:

When I load up the VF page, I get a debug to the console that the component has finished loading (as expected). However, I get two separate, but identical, log messages with the action result. Why are two calls made to the server??

Thanks so much. =)




 
When deploying custom Case fields to one of our sandboxes, the Metadata API is returning Error: limit exceeded failures on all custom fields defined in Case.object. Here is a portion of the build failure output:

[sf:deploy]
*********** DEPLOYMENT FAILED ***********
Request ID: xxx

All Component Failures:
1. objects/Case.object (Case.OC_Project_Due_Date__c) -- Error: limit exceeded (line 3594, column 13)
2. objects/Case.object (Case.Omni_Data_Uploaded_Allocations__c) -- Error: limit exceeded (line 3642, column 13)
3. objects/Case.object (Case.Omni_Data_Uploaded_Assets__c) -- Error: limit exceeded (line 3653, column 13)
4. objects/Case.object (Case.Omni_Data_Uploaded_Characteristics__c) -- Error: limit exceeded (line 3664, column 13)
5. objects/Case.object (Case.Omni_Data_Uploaded_Historical__c) -- Error: limit exceeded (line 3675, column 13)
6. objects/Case.object (Case.Omni_Data_Uploaded_Holdings__c) -- Error: limit exceeded (line 3686, column 13)
7. objects/Case.object (Case.Omni_Data_Uploaded_Performance__c) -- Error: limit exceeded (line 3697, column 13)
8. objects/Case.object (Case.Omni_Data_Uploaded_Personnel__c) -- Error: limit exceeded (line 3708, column 13)
.....

I checked the 'Limits' section for the Case object and it states we're using 2% of our custom Case field allocation (i.e. 15 of 800).

I've confirmed that there are no custom fields in the custom Case field recycle bin.

Anyone know if this is an underlying issue with Salesforce? Refreshing or creating a new sandbox each time we run into this issue is not a good option for us whatsoever.
I'm struggling to understand what kind of restrictions are in place when making a HTTP request to a Salesforce resource within a custom REST endpoint. When I construct the request in a console as such ...
HttpRequest request = new HttpRequest();
request.setEndpoint('https://<my hostname>/apex/MyVisualforcePage');
request.setMethod('GET');
request.setHeader('Authorization', 'Bearer ' + UserInfo.getSessionId());
request.setBody('param1=foo&param2=bar');

HttpResponse response = new Http().send(request);
System.debug(response.getBody());
... I get the page content in HTML correctly.

However, when I make the same call in a custom REST endpoint I get the following output:
\r\n<!DOCTYPE HTML PUBLIC \"-//W3C//DTD HTML 4.01 Transitional//EN\" \"http://www.w3.org/TR/html4/loose.dtd\">\n<html>\n<head>\n    <meta HTTP-EQUIV=\"PRAGMA\" CONTENT=\"NO-CACHE\">\n\n\n\n\n\n<script>\nif (this.SfdcApp && this.SfdcApp.projectOneNavigator) { SfdcApp.projectOneNavigator.handleRedirect('https://evestment--dev.cs13.my.salesforce.com?ec=302&startURL=%2Fapex%2FInvoiceNotificationEmail'); }  else \nif (window.location.replace){ \nwindow.location.replace('https://evestment--dev.cs13.my.salesforce.com?ec=302&startURL=%2Fapex%2FInvoiceNotificationEmail');\n} else {;\nwindow.location.href ='https://evestment--dev.cs13.my.salesforce.com?ec=302&startURL=%2Fapex%2FInvoiceNotificationEmail';\n} \n</script>\n\n</head>\n\n\n</html>\n\n\n\n\n\n<!-- Body events -->\n<script type=\"text/javascript\">function bodyOnLoad(){if(window.PreferenceBits){window.PreferenceBits.prototype.csrfToken=\"null\";};}function bodyOnBeforeUnload(){}function bodyOnFocus(){}function bodyOnUnload(){}</script>\n\t\t\t\n</body>\n</html>\n\n\n<!--\n...................................................................................................\n...................................................................................................\n...................................................................................................\n...................................................................................................\n-->\n\n\n

The response appears to be a page that is redirecting to a login page, but I could be wrong. I'm making the call to the custom REST endpoint via Postman when I received the undesirable output above. I've tried obtaining a session id via Postman and using the same session id in the call to the REST endpoint AND the call to the Salesforce resource (i.e. replacing UserInfo.getSessionId() with the session id). The user authenticating is a sys admin and is the same user running the anonymous code in the console for the positive test.

Can anyone shed any light on why this might be happening?
Hello, there. I'm working on very first Lightning application, and I'm noticing some strange behavior. I'm using a VF page with <apex:includeLightning /> and a script to load a component from an app like so:
 
$Lightning.use("c:OpportunityProductApp", function() {
    $Lightning.createComponent("c:PricebookSelector", {}, "pricebookSelector", function(cmp) {
        console.log('loaded component ...');
	    // do some stuff here
    });
});
The Lightning application is very simple:
 
<aura:application access="GLOBAL" extends="ltng:outApp">
    <c:PricebookSelector />
</aura:application>
The lightning component is as equally simple:
<aura:component controller="PricebookSelectorController">
    <aura:attribute name="pricebooks" type="List" />
    <aura:handler name="init" value="{!this}" action="{!c.doInit}" />
</aura:component>
The component controller looks like this:
({
    doInit : function(component, event, helper) {
        helper.getPricebooks(component);
    }
})
Finally, the component helper looks like this:
({
    getPricebooks: function(component) {
        var action = component.get("c.getPricebooks");

	    var self = this;
	    action.setCallback(this, function(actionResult) {
		    console.log(actionResult);
	    });

	    $A.enqueueAction(action);
    }
})
The problem:

When I load up the VF page, I get a debug to the console that the component has finished loading (as expected). However, I get two separate, but identical, log messages with the action result. Why are two calls made to the server??

Thanks so much. =)




 
When deploying custom Case fields to one of our sandboxes, the Metadata API is returning Error: limit exceeded failures on all custom fields defined in Case.object. Here is a portion of the build failure output:

[sf:deploy]
*********** DEPLOYMENT FAILED ***********
Request ID: xxx

All Component Failures:
1. objects/Case.object (Case.OC_Project_Due_Date__c) -- Error: limit exceeded (line 3594, column 13)
2. objects/Case.object (Case.Omni_Data_Uploaded_Allocations__c) -- Error: limit exceeded (line 3642, column 13)
3. objects/Case.object (Case.Omni_Data_Uploaded_Assets__c) -- Error: limit exceeded (line 3653, column 13)
4. objects/Case.object (Case.Omni_Data_Uploaded_Characteristics__c) -- Error: limit exceeded (line 3664, column 13)
5. objects/Case.object (Case.Omni_Data_Uploaded_Historical__c) -- Error: limit exceeded (line 3675, column 13)
6. objects/Case.object (Case.Omni_Data_Uploaded_Holdings__c) -- Error: limit exceeded (line 3686, column 13)
7. objects/Case.object (Case.Omni_Data_Uploaded_Performance__c) -- Error: limit exceeded (line 3697, column 13)
8. objects/Case.object (Case.Omni_Data_Uploaded_Personnel__c) -- Error: limit exceeded (line 3708, column 13)
.....

I checked the 'Limits' section for the Case object and it states we're using 2% of our custom Case field allocation (i.e. 15 of 800).

I've confirmed that there are no custom fields in the custom Case field recycle bin.

Anyone know if this is an underlying issue with Salesforce? Refreshing or creating a new sandbox each time we run into this issue is not a good option for us whatsoever.
I'm struggling to understand what kind of restrictions are in place when making a HTTP request to a Salesforce resource within a custom REST endpoint. When I construct the request in a console as such ...
HttpRequest request = new HttpRequest();
request.setEndpoint('https://<my hostname>/apex/MyVisualforcePage');
request.setMethod('GET');
request.setHeader('Authorization', 'Bearer ' + UserInfo.getSessionId());
request.setBody('param1=foo&param2=bar');

HttpResponse response = new Http().send(request);
System.debug(response.getBody());
... I get the page content in HTML correctly.

However, when I make the same call in a custom REST endpoint I get the following output:
\r\n<!DOCTYPE HTML PUBLIC \"-//W3C//DTD HTML 4.01 Transitional//EN\" \"http://www.w3.org/TR/html4/loose.dtd\">\n<html>\n<head>\n    <meta HTTP-EQUIV=\"PRAGMA\" CONTENT=\"NO-CACHE\">\n\n\n\n\n\n<script>\nif (this.SfdcApp && this.SfdcApp.projectOneNavigator) { SfdcApp.projectOneNavigator.handleRedirect('https://evestment--dev.cs13.my.salesforce.com?ec=302&startURL=%2Fapex%2FInvoiceNotificationEmail'); }  else \nif (window.location.replace){ \nwindow.location.replace('https://evestment--dev.cs13.my.salesforce.com?ec=302&startURL=%2Fapex%2FInvoiceNotificationEmail');\n} else {;\nwindow.location.href ='https://evestment--dev.cs13.my.salesforce.com?ec=302&startURL=%2Fapex%2FInvoiceNotificationEmail';\n} \n</script>\n\n</head>\n\n\n</html>\n\n\n\n\n\n<!-- Body events -->\n<script type=\"text/javascript\">function bodyOnLoad(){if(window.PreferenceBits){window.PreferenceBits.prototype.csrfToken=\"null\";};}function bodyOnBeforeUnload(){}function bodyOnFocus(){}function bodyOnUnload(){}</script>\n\t\t\t\n</body>\n</html>\n\n\n<!--\n...................................................................................................\n...................................................................................................\n...................................................................................................\n...................................................................................................\n-->\n\n\n

The response appears to be a page that is redirecting to a login page, but I could be wrong. I'm making the call to the custom REST endpoint via Postman when I received the undesirable output above. I've tried obtaining a session id via Postman and using the same session id in the call to the REST endpoint AND the call to the Salesforce resource (i.e. replacing UserInfo.getSessionId() with the session id). The user authenticating is a sys admin and is the same user running the anonymous code in the console for the positive test.

Can anyone shed any light on why this might be happening?
I have a very simple <ui:inputSelectOption> element and a button that calls a controller action that examines the element's label and value. However, the label is "undefined" on the select element.
 
<ui:inputSelect aura:id="pricebooks">
    <ui:inputSelectOption text="" label="--None--" />
    <aura:iteration items="{!v.pricebooks}" var="pricebook">
        <ui:inputSelectOption text="{!pricebook.Id}" label="{!pricebook.Name}" />
    </aura:iteration>
</ui:inputSelect>

<button onclick="{!c.selectPricebook}">Select</button>

Controller code:
({
    selectPricebook: function(component, event, helper) {
        var selectCmp = component.find("pricebooks");
	var value = selectCmp.get("v.value");
        console.log(value); // The expected result
        var label = selectCmp.get("v.label");
        console.log(label); // undefined
})

I've examined the selectCmp object in the debugger and the label property is, in fact, "undefined". What could be the problem here?
Hello, there. I'm working on very first Lightning application, and I'm noticing some strange behavior. I'm using a VF page with <apex:includeLightning /> and a script to load a component from an app like so:
 
$Lightning.use("c:OpportunityProductApp", function() {
    $Lightning.createComponent("c:PricebookSelector", {}, "pricebookSelector", function(cmp) {
        console.log('loaded component ...');
	    // do some stuff here
    });
});
The Lightning application is very simple:
 
<aura:application access="GLOBAL" extends="ltng:outApp">
    <c:PricebookSelector />
</aura:application>
The lightning component is as equally simple:
<aura:component controller="PricebookSelectorController">
    <aura:attribute name="pricebooks" type="List" />
    <aura:handler name="init" value="{!this}" action="{!c.doInit}" />
</aura:component>
The component controller looks like this:
({
    doInit : function(component, event, helper) {
        helper.getPricebooks(component);
    }
})
Finally, the component helper looks like this:
({
    getPricebooks: function(component) {
        var action = component.get("c.getPricebooks");

	    var self = this;
	    action.setCallback(this, function(actionResult) {
		    console.log(actionResult);
	    });

	    $A.enqueueAction(action);
    }
})
The problem:

When I load up the VF page, I get a debug to the console that the component has finished loading (as expected). However, I get two separate, but identical, log messages with the action result. Why are two calls made to the server??

Thanks so much. =)




 
When deploying custom Case fields to one of our sandboxes, the Metadata API is returning Error: limit exceeded failures on all custom fields defined in Case.object. Here is a portion of the build failure output:

[sf:deploy]
*********** DEPLOYMENT FAILED ***********
Request ID: xxx

All Component Failures:
1. objects/Case.object (Case.OC_Project_Due_Date__c) -- Error: limit exceeded (line 3594, column 13)
2. objects/Case.object (Case.Omni_Data_Uploaded_Allocations__c) -- Error: limit exceeded (line 3642, column 13)
3. objects/Case.object (Case.Omni_Data_Uploaded_Assets__c) -- Error: limit exceeded (line 3653, column 13)
4. objects/Case.object (Case.Omni_Data_Uploaded_Characteristics__c) -- Error: limit exceeded (line 3664, column 13)
5. objects/Case.object (Case.Omni_Data_Uploaded_Historical__c) -- Error: limit exceeded (line 3675, column 13)
6. objects/Case.object (Case.Omni_Data_Uploaded_Holdings__c) -- Error: limit exceeded (line 3686, column 13)
7. objects/Case.object (Case.Omni_Data_Uploaded_Performance__c) -- Error: limit exceeded (line 3697, column 13)
8. objects/Case.object (Case.Omni_Data_Uploaded_Personnel__c) -- Error: limit exceeded (line 3708, column 13)
.....

I checked the 'Limits' section for the Case object and it states we're using 2% of our custom Case field allocation (i.e. 15 of 800).

I've confirmed that there are no custom fields in the custom Case field recycle bin.

Anyone know if this is an underlying issue with Salesforce? Refreshing or creating a new sandbox each time we run into this issue is not a good option for us whatsoever.