• tgeisse
  • NEWBIE
  • 0 Points
  • Member since 2012

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

I've spent awhile trying to find a solution to this, but I haven't been able to perfect my googling. I am trying to define a new Hierarchy Custom Setting in my org, but cannot seem to read the values in APEX.

 

My custom settings API name is Import_Summary_Email__c and I have two fields on it:

Email_Summary_To_Org_Owner__c which is a checkbox

test__c which is a number

 

I have an Organization defualt, a profile-level setting, and a user-level setting defined.

 

  SetupOwnerId IsDeleted Email_Summary_To_Org_Owner__c test__c

1005U0000000Rh5vIACfalsetrue75.0
200eU0000000nyDuIAIfalsefalse150.0
300DU0000000JiHKMA0falsetrue100.0

 

When I run the following (error level is so that it stands out):

 

Import_Summary_Email__c emailSettings = Import_Summary_Email__c.getInstance();
System.debug(LoggingLevel.ERROR,emailSettings);
System.debug(LoggingLevel.ERROR,emailSettings.Email_Summary_To_Org_Owner__c);

 I get this as my output in the debug log:

 

13:20:36.158 (8158270000)|USER_DEBUG|[96]|ERROR|rr2__Import_Summary_Email__c:{SetupOwnerId=005U0000000Rh5vIAC}
13:20:36.158 (8158344000)|USER_DEBUG|[97]|ERROR|false

 

If I'm reading this right, then getInstance() is working. Or maybe it's not? Am I missing something in the setup or in the lines of my code?

 

Thanks for your help!

I've spent awhile trying to find a solution to this, but I haven't been able to perfect my googling. I am trying to define a new Hierarchy Custom Setting in my org, but cannot seem to read the values in APEX.

 

My custom settings API name is Import_Summary_Email__c and I have two fields on it:

Email_Summary_To_Org_Owner__c which is a checkbox

test__c which is a number

 

I have an Organization defualt, a profile-level setting, and a user-level setting defined.

 

  SetupOwnerId IsDeleted Email_Summary_To_Org_Owner__c test__c

1005U0000000Rh5vIACfalsetrue75.0
200eU0000000nyDuIAIfalsefalse150.0
300DU0000000JiHKMA0falsetrue100.0

 

When I run the following (error level is so that it stands out):

 

Import_Summary_Email__c emailSettings = Import_Summary_Email__c.getInstance();
System.debug(LoggingLevel.ERROR,emailSettings);
System.debug(LoggingLevel.ERROR,emailSettings.Email_Summary_To_Org_Owner__c);

 I get this as my output in the debug log:

 

13:20:36.158 (8158270000)|USER_DEBUG|[96]|ERROR|rr2__Import_Summary_Email__c:{SetupOwnerId=005U0000000Rh5vIAC}
13:20:36.158 (8158344000)|USER_DEBUG|[97]|ERROR|false

 

If I'm reading this right, then getInstance() is working. Or maybe it's not? Am I missing something in the setup or in the lines of my code?

 

Thanks for your help!

I want to embed javascript coding in visualforce. The javascript coding is for integrating 'Bitly' platform with salesforce.

 

My visualforce code is:

 

<apex:form >
<apex:inputText value="{!Candidate__c.Long_Url__c}" id="theText" onclick="javascript&colon;go('{!$Component.theText}')" ></apex:inputText>

  <script type="text/javascript" src="/js/functions.js"></script>
    <script src="/soap/ajax/11.1/connection.js"></script>
    
   <script language="javascript">
    
   function go(f) {
    var theText = document.getElementById(f).value;
   alert(theText);
   }
var xhr = new XMLHttpRequest(); 

xhr.open("GET", "http://api.bitly.com//v3/shorten?login=tseth&apiKey=R_948fa681da46221f969e83b2ba52d31e&longUrl="+theText);

xhr.onreadystatechange = function(){ 

alert('test');
if(xhr.readyState == 4) { 
if(xhr.status==200) { 
var jsonResponse = JSON.parse(xhr.responseText);
var bitlyUrl = jsonResponse.data.url; 

myFunc(bitlyUrl);
var t = xhr.send();
}
}
}

</script>
</apex:form>
<apex:form >
<apex:actionFunction name="myFunc" action="{!field}">
<apex:param name="param1" value=""/>
</apex:actionFunction>
</apex:form>

</apex:page>

 

Bitly is used for URL shortening. I want the shortened url to be passed to the controller through <apex:actionfunction>.

 

Please help. Its really urgent. I am completely stuck.

 

Thanks