• Kellymt
  • NEWBIE
  • 55 Points
  • Member since 2013

  • Chatter
    Feed
  • 1
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 11
    Questions
  • 11
    Replies
We have an managed package which references settings stored in static resource which is not part of the managed package. We want to keep the static resource not a part of the managed package because we want to let the user modify those settings. 
Could you please let me know what is the best practices way to referene static resources not part of a managed package wtihin Visualforce page which is part of a managed package. 
We cannot use URLFOR because that would require the resource to be a part of the package. 
If we handcraft the url like this <apex:includeScript value="/resource/1463666571000/foo" />
The resource would not be loaded because the absolute url will be https://MANAGEDPACKAGEPREFIX.cs80.visual.force.com/resource/1463666571000/foo and Salesforce will not find it because the resource sits here: 
https://c.cs80.visual.force.com/resource/1463666571000/foo

Thanks!
I have a lightning component which invokes a third party popup window as a lightbox. The window is served from another domain.
I would like for when that thrid party window closes to call a JavaScript method in my Lightning component to receive some data. 

The best way I found to pass the results is via window.postMessage because the thirda party window and the lightning components are from different domains. 
The quiestion I have is how to receid that postMessage even from my Lightning component. 

I tried adding the below method to my Lighting component's controller but it did not work: 
 doInit : function(component, event, helper) {
        var listener = function(event) {
           //Do work here
       }
        if (addEventListener){
              addEventListener("message", listener, false);
        } else {
              attachEvent("onmessage", listener);
        }
    },

Could you please help me figure this out.
We have setup a Salesforce Community and have turned on the "IP Restrict Requests" setting on the user's profile.
We have an apex class (see below) which makes a call out to the SOAP API to retrieve the layout metadata for an sObject. The exact method we call is GetLayout and the SOAP API endpoint we are hitting is 'https://SALESFORCEDOMAIN/services/Soap/u/32.0' where SALESFORCEDOMAIN is the domain of the account.
The problem we are having is that calling out to the SOAP API fails with INSUFFICIENT_ACCESS. If we disable "IP Restrict Requests" or enter in the IP ranges table for the profile the range 0.0.0.0 - 255.255.255.4 the call succeeds.
If we enter all Salesforce IP ranges published online the call fails. I think that because our Apex class makes the request to Salesforce itslef that I need to whitelist Salesforce's IPs for the callout to succeed but that is not the case.
Does anybody know what range should I have in my IP table for the call to succeed? 
 
Code: 

public String GetLayout(String sObjectName, String recordTypeId) {
    String requestXml = GetDescribeLayoutRequestXml(sObjectName, System.UserInfo.getSessionId());
    String responseXml = ExecuteRequest('Something', requestXml); //KM: The service does not return anything without soap action. The soap action value does not matter.
    
    return responseXml ;

 private String GetDescribeLayoutRequestXml(String sObjectName, String sessionId) {
    String xml = '<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:urn="urn:partner.soap.sforce.com" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"> \n' +
                    '<soapenv:Header> \n' + 
                        '<urn:SessionHeader> \n' + 
                            '<urn:sessionId>{0}</urn:sessionId> \n' + 
                        '</urn:SessionHeader> \n' + 
                    '</soapenv:Header> \n' + 
                    '<soapenv:Body> \n' + 
                        '<urn:describeLayout> \n' + 
                            '<urn:sObjectType>{1}</urn:sObjectType> \n' + 
                            '<urn:layoutName xsi:nil="true" /> \n' + 
                        '</urn:describeLayout> \n' + 
                    '</soapenv:Body> \n' + 
                '</soapenv:Envelope> \n';
                
    List<String> prms = new List<String>();
    prms.add(sessionId);   //{0}
    prms.add(sObjectName); //{1}
    
    return String.format(xml, prms);
}
private static string ExecuteRequest(String soapAction, String requestXml) {
    HttpRequest req = new HttpRequest();
    req.setTimeout(120000); 
    req.setEndpoint('https://SALESFORCEDOMAIN/services/Soap/u/32.0');
    req.setHeader('Content-Type','text/xml');
    req.setHeader('SOAPAction', soapAction);
    req.setMethod('GET');
    req.setBody(requestXml);
    
    Http h = new Http();               
    HttpResponse res = h.send(req);
    dom.Document doc = res.getBodyDocument();  
    
    return doc.toXmlString();       
}    
  • September 30, 2015
  • Like
  • 0
I have been using the well known HTML home page component workaround and later the Links home page workaround to inject javascript onto Salesforce standard pages. 
I see that in winter 16 Salesforce have changed the way javascript is included when using the "INCLUDESCRIPT()" macro in a custom links component so that your script is inly included if a user clicks on your home page component link thus my functionality will not be automatically invoked any longer.

Does anyone have a new workaround on how to inject JavaScript onto standard VF pages?
I have multiple managed packages installed in my account and I would like to find out which application is making API calls.
I would also want ot find out the Application Id for the package which makes the callouts. 

Thanks!
We have developed a connected app in C# which we have exposed as a web tab in salesforce.com and which authenticates via AOuth.
Users login to salesforce.com click on the web tab and out application authenticates with AOuth and can make queries to salesforce.com.

The question I have is how to log out/ invalidate the AOuth token of out applicaiton when the user logs out of salesforce.com?
If we do not do that our application will pratically remain logged in even after the user logs out of salesforce.com until the session expired due to inactivity which is a security risk.
 
Hi,
I am trying to call a webservice on the Govt Cloud (sandbox instance cs32) and the callout fails intermitantly with the following two error messages: 
"Server choose TLSv1, but that protocol version is not enabled or not supported by the client"
"Read timeout" after it request hung for 2 minutes.
The call also sometimes succeeds. 
I have contacted salesforce.com suggesting that this is a bug or something may be wrong with that particular instance but they have closed the case. 
Exactly the same code works consistently in all several other instances of Salesforce.com like eu1, NA13 etc. 

I am making the call from the Developer Console from the Execute Anonimous window and it is: 
String url = 'ENDPOINT';
String requestXml = 'XML_MESSAGE_FOR_THE_CALL';

HttpRequest req = new HttpRequest();
req.setTimeout(120000);
req.setEndpoint(url);
req.setHeader('Content-Type','text/xml');
req.setHeader('SOAPAction', 'SOAP_ACTION');
req.setMethod('POST');
req.setBody(requestXml);

Http h = new Http();
HttpResponse res = h.send(req);

dom.Document doc = res.getBodyDocument();
System.debug(doc.toXmlString());

Where ENDPOINT, XML_MESSAGE_FOR_THE_CALL and SOAP_ACTION are substituted with the corresponding correct values. 
Initailly the endopint only supported TLSv1 but later we added support for  TLSv1.1 and TLSv1.2  and we are still having problems. 
I have also tried calling out to other https endpoint like https://maps.google.com which did not work. 
I tried calling out to the salesforce.com soap API to another account which worked correclty every time thus it must not be a generic problem with all ssl callouts. 

Does anybody have any ideas on what could be wrong?

Thanks,
Kzmp
We have created a custom sObject Address which is linked to Account in a Child-Parent way. So that one Account has multiple Addresses. We have added the Address sObject as a related list to our Account layout.
Does anybody know how can we configure the Address to open as a primary tab instead of a sub tab in the Salesforce.com Console when we open it from the Account related list?

Thank you!
Does anybody know how can I find the layout assigned to a particular user from Apex?
I know that the Metadata API will give me that information:   
 MetadataService.Profile profile = (MetadataService.Profile)service.readMetadata('Profile', new String[] { profileName }).getRecords()[0];
           for(MetadataService.ProfileLayoutAssignment layoutAssignment : profile.layoutAssignments) {
               if(layoutAssignment.layout.startsWith('Account')) {
                   accountLayoutName = layoutAssignment.layout;
                   break;         
               }
           }
but the metadata API is not available from within Apex and using the MetadataService provided by FinancialForce.com (great job guys) seems like an overkill to me.
Also does anybody know if the MetadataAPI counts towards your API call limits?

Thanks,
Kzmp
Hi,
Does anyone know whether there is any prerequisite to the Force.com Advanced Developer exams?
Do I need to posses the Force.com Developer exam before I can sign for the Force.com Advanced Developer exam?

Kos

Hi,

 

Is state and country picklist beta in Summer 13?

 

Thanks,

Kelly

We have an managed package which references settings stored in static resource which is not part of the managed package. We want to keep the static resource not a part of the managed package because we want to let the user modify those settings. 
Could you please let me know what is the best practices way to referene static resources not part of a managed package wtihin Visualforce page which is part of a managed package. 
We cannot use URLFOR because that would require the resource to be a part of the package. 
If we handcraft the url like this <apex:includeScript value="/resource/1463666571000/foo" />
The resource would not be loaded because the absolute url will be https://MANAGEDPACKAGEPREFIX.cs80.visual.force.com/resource/1463666571000/foo and Salesforce will not find it because the resource sits here: 
https://c.cs80.visual.force.com/resource/1463666571000/foo

Thanks!
I have a lightning component which invokes a third party popup window as a lightbox. The window is served from another domain.
I would like for when that thrid party window closes to call a JavaScript method in my Lightning component to receive some data. 

The best way I found to pass the results is via window.postMessage because the thirda party window and the lightning components are from different domains. 
The quiestion I have is how to receid that postMessage even from my Lightning component. 

I tried adding the below method to my Lighting component's controller but it did not work: 
 doInit : function(component, event, helper) {
        var listener = function(event) {
           //Do work here
       }
        if (addEventListener){
              addEventListener("message", listener, false);
        } else {
              attachEvent("onmessage", listener);
        }
    },

Could you please help me figure this out.
We have setup a Salesforce Community and have turned on the "IP Restrict Requests" setting on the user's profile.
We have an apex class (see below) which makes a call out to the SOAP API to retrieve the layout metadata for an sObject. The exact method we call is GetLayout and the SOAP API endpoint we are hitting is 'https://SALESFORCEDOMAIN/services/Soap/u/32.0' where SALESFORCEDOMAIN is the domain of the account.
The problem we are having is that calling out to the SOAP API fails with INSUFFICIENT_ACCESS. If we disable "IP Restrict Requests" or enter in the IP ranges table for the profile the range 0.0.0.0 - 255.255.255.4 the call succeeds.
If we enter all Salesforce IP ranges published online the call fails. I think that because our Apex class makes the request to Salesforce itslef that I need to whitelist Salesforce's IPs for the callout to succeed but that is not the case.
Does anybody know what range should I have in my IP table for the call to succeed? 
 
Code: 

public String GetLayout(String sObjectName, String recordTypeId) {
    String requestXml = GetDescribeLayoutRequestXml(sObjectName, System.UserInfo.getSessionId());
    String responseXml = ExecuteRequest('Something', requestXml); //KM: The service does not return anything without soap action. The soap action value does not matter.
    
    return responseXml ;

 private String GetDescribeLayoutRequestXml(String sObjectName, String sessionId) {
    String xml = '<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:urn="urn:partner.soap.sforce.com" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"> \n' +
                    '<soapenv:Header> \n' + 
                        '<urn:SessionHeader> \n' + 
                            '<urn:sessionId>{0}</urn:sessionId> \n' + 
                        '</urn:SessionHeader> \n' + 
                    '</soapenv:Header> \n' + 
                    '<soapenv:Body> \n' + 
                        '<urn:describeLayout> \n' + 
                            '<urn:sObjectType>{1}</urn:sObjectType> \n' + 
                            '<urn:layoutName xsi:nil="true" /> \n' + 
                        '</urn:describeLayout> \n' + 
                    '</soapenv:Body> \n' + 
                '</soapenv:Envelope> \n';
                
    List<String> prms = new List<String>();
    prms.add(sessionId);   //{0}
    prms.add(sObjectName); //{1}
    
    return String.format(xml, prms);
}
private static string ExecuteRequest(String soapAction, String requestXml) {
    HttpRequest req = new HttpRequest();
    req.setTimeout(120000); 
    req.setEndpoint('https://SALESFORCEDOMAIN/services/Soap/u/32.0');
    req.setHeader('Content-Type','text/xml');
    req.setHeader('SOAPAction', soapAction);
    req.setMethod('GET');
    req.setBody(requestXml);
    
    Http h = new Http();               
    HttpResponse res = h.send(req);
    dom.Document doc = res.getBodyDocument();  
    
    return doc.toXmlString();       
}    
  • September 30, 2015
  • Like
  • 0
I have been using the well known HTML home page component workaround and later the Links home page workaround to inject javascript onto Salesforce standard pages. 
I see that in winter 16 Salesforce have changed the way javascript is included when using the "INCLUDESCRIPT()" macro in a custom links component so that your script is inly included if a user clicks on your home page component link thus my functionality will not be automatically invoked any longer.

Does anyone have a new workaround on how to inject JavaScript onto standard VF pages?
We have developed a connected app in C# which we have exposed as a web tab in salesforce.com and which authenticates via AOuth.
Users login to salesforce.com click on the web tab and out application authenticates with AOuth and can make queries to salesforce.com.

The question I have is how to log out/ invalidate the AOuth token of out applicaiton when the user logs out of salesforce.com?
If we do not do that our application will pratically remain logged in even after the user logs out of salesforce.com until the session expired due to inactivity which is a security risk.
 
We have created a custom sObject Address which is linked to Account in a Child-Parent way. So that one Account has multiple Addresses. We have added the Address sObject as a related list to our Account layout.
Does anybody know how can we configure the Address to open as a primary tab instead of a sub tab in the Salesforce.com Console when we open it from the Account related list?

Thank you!
Does anybody know how can I find the layout assigned to a particular user from Apex?
I know that the Metadata API will give me that information:   
 MetadataService.Profile profile = (MetadataService.Profile)service.readMetadata('Profile', new String[] { profileName }).getRecords()[0];
           for(MetadataService.ProfileLayoutAssignment layoutAssignment : profile.layoutAssignments) {
               if(layoutAssignment.layout.startsWith('Account')) {
                   accountLayoutName = layoutAssignment.layout;
                   break;         
               }
           }
but the metadata API is not available from within Apex and using the MetadataService provided by FinancialForce.com (great job guys) seems like an overkill to me.
Also does anybody know if the MetadataAPI counts towards your API call limits?

Thanks,
Kzmp
Hi,
Does anyone know whether there is any prerequisite to the Force.com Advanced Developer exams?
Do I need to posses the Force.com Developer exam before I can sign for the Force.com Advanced Developer exam?

Kos

Hi,

 

Is state and country picklist beta in Summer 13?

 

Thanks,

Kelly