• Angulix
  • NEWBIE
  • 15 Points
  • Member since 2015

  • Chatter
    Feed
  • 0
    Best Answers
  • 10
    Likes Received
  • 0
    Likes Given
  • 3
    Questions
  • 7
    Replies
Hi,
I need to pass a method name as argument. How can I do that ?
This is my practical case, the String.join() can only read list of String. But I want it to work for a list of object (in my case: cMyObject). The object will have a function to send back the proper string (here: getFormattedStr()). I want to make a function "getListOfStringForJoin" that receive the function getFormattedStr() as argument. As Apex is object oriented, I guess it is possible.

public class cMyObject {
... all stuff as constructor, internal properties...
public String getFormattedStr() {
return ... a Formatted Str ...;
}
}
 
list<cMyObject> vListMyObject = new list<cMyObject>();

public list<String> getListOfStringForJoin( list<object> pList, function pFuncName ) {
list<String> tOutList = new list<String>();
for( Integer tIter = 0; tIter < pList.size(); tIter++) {
tOutList.add( pList[ tIter ].pFuncName() );
}
return tOutList;
}

outStr = join( getListOfStringForJoin( vListMyObject, getFormattedStr ), ', ' );

Thanks a lot for tips and thoughts !
Hi,
It is not a question, I share my experience because I spent hours on this...
on my visualforce page, chrome kept telling me (in the Javascript console):
XMLHttpRequest cannot load https://eu3.salesforce.com/_ui/common/request/servlet/JsLoggingServlet.
No 'Access-Control-Allow-Origin' header is present on the requested resource.
Origin 'https://c.eu3.visual.force.com' is therefore not allowed access.
Browsing the net, I didn't find info on this error.
At the end, It appears this was due to a call to the "alert" javascript box just before the call to an "<apex:actionFunction". See below,
Javascript is:
function jsRemoveLineItemCatBtn() {
alert( 'CURRENT ID ' + vLICInProgressNum );
afRemoveLineItemCatBtn( String(vLICInProgressNum) );
}
where afRemoveLineItemCatBtn is the name of my action function.
Since I commented the call to alert, I don't have the error message anymore...
Hope to help few to save time.
 
Hi, 
How can I propose to my users a box where they can build filtering conditions based on database fields (like the filtering conditions when creating a report).

Example

accound.closedate < 2015-06-30
and 
account.territorry__c in ('EMEA','US')

Kindly point me to the right documentation piece if any

Thanks a lot for help
 
Hi,
It is not a question, I share my experience because I spent hours on this...
on my visualforce page, chrome kept telling me (in the Javascript console):
XMLHttpRequest cannot load https://eu3.salesforce.com/_ui/common/request/servlet/JsLoggingServlet.
No 'Access-Control-Allow-Origin' header is present on the requested resource.
Origin 'https://c.eu3.visual.force.com' is therefore not allowed access.
Browsing the net, I didn't find info on this error.
At the end, It appears this was due to a call to the "alert" javascript box just before the call to an "<apex:actionFunction". See below,
Javascript is:
function jsRemoveLineItemCatBtn() {
alert( 'CURRENT ID ' + vLICInProgressNum );
afRemoveLineItemCatBtn( String(vLICInProgressNum) );
}
where afRemoveLineItemCatBtn is the name of my action function.
Since I commented the call to alert, I don't have the error message anymore...
Hope to help few to save time.
 
I wanted to create the Visualforce Page using Apex Class. But when i use the extensions command system says the given class name is not found and not given me an option to create the Apex Class.

 
Hi, 
How can I propose to my users a box where they can build filtering conditions based on database fields (like the filtering conditions when creating a report).

Example

accound.closedate < 2015-06-30
and 
account.territorry__c in ('EMEA','US')

Kindly point me to the right documentation piece if any

Thanks a lot for help
 

Does anyone have experience with using jQuery or the HTML5 "Draggable" feature to implement drag-and-drop capabilites? It seems like every tutorial I find on the web conflicts with the extJS and other internal SF javascript libraries. Any thoughts? Thanks

 

This is just some example code, I don't want the focus of what I'm doing to cloud the concept I'm trying to figure out.

 

code:

 

sobject[] something = [SELECT Contact.FirstName, Contact.Account.Name, contact.account.type from Contact];

 

I've used sobject[] here instead of contact[] because in my project the query is dynamic and could be from a different table.

 

My question is, how do I get the relationship field from this? Normally, I know you can do this:

 

string theName = something[0].Account.Name;

 

However, this results in the error: Field expression not allowed for generic SObject

 

How do I get around this?

  • April 29, 2012
  • Like
  • 1

Hi All,

 

I want to get all fieldnames of a object in apex. How can I do this?

 

For example for User object I want to get all its field names like AboutMe, AccountId , Email etc.

 

Any help on this really appreciated.

 

Regards,

Naren

  • January 18, 2012
  • Like
  • 0

I  have two selectList,list1 and list2. the option of list2 is add according the selected item in list1 automaticly in javascript.

the code is:

 

<script>
 var hotel=new Array();
 var brand=new Array();
 var type=new Array();
 <apex:outputText escape="false" value="{!MyHotel}"></apex:outputText>
 <apex:outputText escape="false" value="{!MyBrand}"></apex:outputText>
 <apex:outputText escape="false" value="{!MyType}"></apex:outputText>
function list2(list2id,n)
{
 var list=document.getElementById(list2id);


 for(var i=list.length-1;i>=0;i--)list.remove(i);
 for(var i=0;i<hotel.length;i++)
 list.add(new Option(hotel[i],hotel[i]));
 }
</script>
<apex:outputPanel id="result">
<apex:form >
<b>Report By: </b>
<apex:selectList id="list1" multiselect="false"  size="1" value="{!reporttype}"  onchange="list2('{!$Component.list2}');">
<apex:selectOption itemValue="1" itemLabel="Hotel"></apex:selectOption>
<apex:selectOption itemValue="2" itemLabel="Hotel Brand"></apex:selectOption>
<apex:selectOption itemValue="3" itemLabel="Hotel Type"></apex:selectOption>
</apex:selectList>
<b>Please select :</b>
<apex:selectList id="list2" multiselect="false" size="1" value="{!reportby}">
</apex:selectList>
<apex:commandButton value="Go!" action="{!doSearch}" status="status"  reRender="result"/>

<apex:form>

</apex:outputPanel >

 

the problem is I can't get the value of reportby in my apex, where is the problem?