• keshin okawa
  • NEWBIE
  • 65 Points
  • Member since 2015

  • Chatter
    Feed
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 14
    Questions
  • 14
    Replies
public class formBuilderClass {

        public Map<String,List<String>> objectFieldMap {
          get {
              if(objectFieldMap == null) {
                  objectFieldMap = new Map<String,List<String>>();
              }
              return objectFieldMap;
          }
          set;
        }

        public void viewMap() {
            System.debug('wew objectFieldmap' + objectFieldMap);
        }
    }
And then I've created a visual force page that includes pageBlockTable and a script to insert data to the table which is something like this.
<apex:pageBlock >
      <apex:pageBlockTable value="{!objectFieldMap}" var="field" styleClass="table table-striped" id="tableField">
        <apex:column width="30%" value="{!objectFieldMap[field][0]}" headerValue="SALESFORCE FIELD" styleClass="wew" />
        <apex:column width="30%" value="{!objectFieldMap[field][1]}" headerValue="CSV FIELD" styleClass="wew" />
      </apex:pageBlockTable>
    </apex:pageBlock>

    <apex:commandButton value="Submit" action="{!viewMap}" styleClass="btn btn-block btn-strong-green"/>


<script>
    $(document).ready(function(){
        $('[id$="tableField"]').append('<tr><td>sample data 1</td><td>sample data 2</td></tr>') ;
    });
</script>
What I want to accomplished, is that I want to get all the data appended to the table using javascript. So that, when I clicked the submit button I can see the new value for my objectFieldMap variable. Is it possible ? or are there any easier way to do a scenario which is something like this ? please help. Thank you...
Good day everyone,

I have created a wrapper class which is something like this:
public class wrapperClass {
        public Map<String,List<String>> selectedDefinitionList{get;set;}
        public Boolean isSelect{get;set;}
        public wrapperClass(Map<String,List<String>> selectedDefinitionList, boolean isSelect ) {
            this.selectedDefinitionList = selectedDefinitionList;
            this.isSelect = isSelect;
        }
    }

The purpose of this wrapper class is to combine the value of a map and a checkbox. At the moment I've tried to view the data of my wrapper and it is working as expected, but my problem is that how will i show the data of my wrapper specifically the map in it to my visual force page(pageblockTable). I've made something like this :
<apex:pageBlock > 
<apex:pageBlockTable value="{!AllObjectFieldMap}" var="field" styleClass="table table-striped">
<apex:column value="{!field.selectedDefinitionList}" headerValue="Salesforce Field"/>
</apex:pageBlockTable> 
</apex:pageBlock>
But I cannot see those data inside my map. I think I am lacking something. Please help thank you...
 
I am almost done with my test class and I ended up with 2 lines in my class that are not covered by my test class.

        if(Integer.valueOf(System.Today().month()) - 1 == 0) {
            mMonth = '12';
             mYear = String.valueOf(Integer.valueOf(System.Today().year()) - 1);

         } else {
            mMonth= String.valueOf(Integer.valueOf(System.Today().month()) - 1);
             mYear = String.valueOf(Integer.valueOf(System.Today().year()));
         } 
How do I cover the 2 lines of code ( bold ones )?
Some of my other classes also uses that same lines of code. Thanks!!
Hi everyone. I used PageBlockTableEnhancer to show my records from an object. The problem is I can't list more than 1k records due to limits so I searched and found that you can with JSremoting from here @http://blogforce9.blogspot.com/2014/10/showing-more-than-1k-records-using-pbe.html . I was able to display 1.4k records successfully but I noticed that lookup data is only shown as ID and is just considered text. Is there a workaround for it to behave the same as without using JSremoting? The lookup data shows fine with just PageBlockTableEnhancer.
 


User-added image

 
my sample csv contains this code

User,Monthly Income,Age,Debt,Gender,
John Doe,"$30,000.00",35,"$2,000.00",Male,
Mary Smith,"$20,000.00",30,"$900.00",Female,

the code I'm following only has this code for the CSV part

csvAsString = csvFileBody.toString();
csvFileLines = csvAsString.split('\n');
string[] csvRecordData = csvFileLines[0].split(',');


I tried looking for solutions about this problem and the closest I found is this
https://developer.salesforce.com/forums/ForumsMain?id=906F000000092l6IAA

Does anyone have a better idea/code to deal with this problem?
 
I have some code that displays dynamic values in a selectlist

                <apex:pageBlock >
                    <apex:pageBlockTable value="{!Sample}" var="field" styleClass="table table-striped">
                        <apex:column value="{!Sample[field][0]}" headerValue="Salesforce Field"/>
                        <apex:column headerValue="CSV Field">
                             <apex:selectList value="{!Sample[field][1]}" styleClass="form-control" size="1">
                                 <apex:selectOptions value="{!csvField}"/>
                             </apex:selectList>
                         </apex:column>
                         <apex:column >
                         </apex:column>
                    </apex:pageBlockTable>
                </apex:pageBlock>

the problem is I want to remove the value that one selectlist has chosen
ex. options = Name, Gender, Age
I want to remove Name from other selectlist if one of the selectlist chooses it. It's my first time so I don't know how to do it.
The dynamic values in the selectlist are from an uploaded csv file.
Good day everyone I have some question in salesforce. Suppose i've created a map example:
map<String,String> testVariable =  new map<String,String>  // where the map key is an api key of a certain object field and map value is a possible field value;

Now what I want is to create an object through looping the map.Ex.

Account acctVariable = new Account();
for(String variable1 : testVariable.keyset()){
    acctVariable.variable1 = 'sample data';
}

But an error say that "Invalid field variable1". What will I do in order for the system to detect that variable1 is a variable and not an object field ?This is just a part of the whole code. Please help .thank you.
I'm used to making test classes for inserting data in Objects but I'm kinda lost in making test data for this code...
(It retrieves the custom field names of my Custom Object mMovie__c)

public class objectlist {

  public List<string> fieldLabel {get;set;}
  
  public objectlist()
  {
    this.getAccountFields();
  }

  public void getAccountFields()
  {
          Map<String, Schema.SObjectType> gd = Schema.getGlobalDescribe();
          fieldLabel = new List<string>();      
          Map <String, Schema.SObjectField> fieldMap = gd.get('mMovie__c').getDescribe().fields.getMap();
          for(Schema.SObjectField fieldAPI : fieldMap.values())
          {     
              // if(fieldAPI.getDescribe().isCustom() )
              //{
               fieldLabel.add(fieldAPI.getDescribe().getLabel());
              //}
          }
          fieldLabel.sort();
          system.debug('fieldLabel-----'+fieldLabel);
  }     
}

 
I was able to utilize some code I found online and finally come up with this one..

Class
----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
public with sharing class Describer
{
public Map <String, Schema.SObjectType> schemaMap = Schema.getGlobalDescribe();
public List<Pair> lstfieldname{get;set;}
public List <Pair> fields {get{return lstfieldname;} set{lstfieldname =value;}}

// Intialize objectNames and fields
public Describer() {
    fields = new List<Pair>();
    showFields();
}

// Find the fields for WRAP Report Object

public void showFields() {

Map <String, Schema.SObjectField> fieldMap = schemaMap.get('Sample__c').getDescribe().fields.getMap();
for(Schema.SObjectField sfield : fieldMap.Values())
    {
        schema.describefieldresult dfield = sfield.getDescribe();
        system.debug('#######' + dfield );
        Pair field = new Pair();
        field.key = dfield.getname();
        system.debug('#######4444' + field.key);
        field.val =dfield.getLabel ();
        lstfieldname.add(field);
    }
}

public class Pair
{
    public String key {get; set;}
    public String val {get; set;}
}
}

Visualforce page
-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
<apex:page Controller="Describer">
    <apex:form id="Describe">
        <apex:pageBlock title="Salesforce Field">
            <apex:pageBlockTable value="{!fields}" var="fls" styleClass="table table-striped">
                <apex:column value="{!fls.val}"/>
                <!-- Header Generated automatically -->
            </apex:pageBlockTable>
        </apex:pageBlock>
    </apex:form>
</apex:page>
--------------------------------------------------------------------------------------------------------------------------------------------------------
The result was this

Name
Address
Gender
Age
Nationality

1. I need some kind of explanation about the flow of the class code (I know what the code does but i'm not familiar with most parts of it).
2. How do I sort the results alphabetically (to make it easier to locate a field)?
 
here is my code...

public class objectlist {
    //Do not forget to get instance in constructor for this list
    //String type='Account';
     Map<String, Schema.SObjectType> gd = Schema.getGlobalDescribe();
       List<string> fieldLable = new List<string>();
        
       Map <String, Schema.SObjectField> fieldMap = gd.get('Account').getDescribe().fields.getMap();
       for(Schema.SObjectField fieldAPI : fieldMap.values())
       {
               fieldLable.add(+ '<' +fieldAPI.getDescribe().getName()+ '/>' );
       }
       
       system.debug('fieldLable-----'+fieldLable);
}

IDK what part is wrong...pls help me fix this...THX!!!
I'm new at remote objects and I was wondering on how to add pagination to this sample page which uses remote object (Contact).
@https://gist.github.com/Karanraj/3f7e7684f096b6956c27#file-vfremoteobject-html
Pls do link me the js you're gonna use for the pagination.

THX in Advance !!
I followed the steps from here @https://developer.salesforce.com/docs/atlas.en-us.lightning.meta/lightning/qs_aotp_app_step1.htm and an error "e is null" shows everytime I clicked submit but it adds new portions(each new expense) in the button with blank values. I tried using console.log and it displays values. I also already added the custom object with the fields. The only difference I have from the given codes is that I don't use namespace. I hope anyone who has the same issue or has any idea how to solve this..pls do share here...
User-added image
I encountered something like this through https://developer.salesforce.com/docs/atlas.en-us.lightning.meta/lightning/qs_aotp_app_step4_nested.htm
and I can't figure out how to save my form.cmp because I ddnt use any namespace on my developer account. I tried some ways but I can't seem to igure it out on my own and I don't have much experience with it. Any suggestions/solutions will be a great help to me...
I think I did everything listed in the challenge but I keep on getting this...

" Challenge not yet complete... here's what's wrong:
The process did not set the correct Type value on submitting for approval "


I already put an initial submission action:
-Field Update
-Object Account    
-Field to Update Account: Type
-Field Data Type Picklist
-a specific value: PENDING

i dont know what else to change...pls give me some ideas...routing records with approval process error
I am almost done with my test class and I ended up with 2 lines in my class that are not covered by my test class.

        if(Integer.valueOf(System.Today().month()) - 1 == 0) {
            mMonth = '12';
             mYear = String.valueOf(Integer.valueOf(System.Today().year()) - 1);

         } else {
            mMonth= String.valueOf(Integer.valueOf(System.Today().month()) - 1);
             mYear = String.valueOf(Integer.valueOf(System.Today().year()));
         } 
How do I cover the 2 lines of code ( bold ones )?
Some of my other classes also uses that same lines of code. Thanks!!
Hi everyone. I used PageBlockTableEnhancer to show my records from an object. The problem is I can't list more than 1k records due to limits so I searched and found that you can with JSremoting from here @http://blogforce9.blogspot.com/2014/10/showing-more-than-1k-records-using-pbe.html . I was able to display 1.4k records successfully but I noticed that lookup data is only shown as ID and is just considered text. Is there a workaround for it to behave the same as without using JSremoting? The lookup data shows fine with just PageBlockTableEnhancer.
 


User-added image

 
my sample csv contains this code

User,Monthly Income,Age,Debt,Gender,
John Doe,"$30,000.00",35,"$2,000.00",Male,
Mary Smith,"$20,000.00",30,"$900.00",Female,

the code I'm following only has this code for the CSV part

csvAsString = csvFileBody.toString();
csvFileLines = csvAsString.split('\n');
string[] csvRecordData = csvFileLines[0].split(',');


I tried looking for solutions about this problem and the closest I found is this
https://developer.salesforce.com/forums/ForumsMain?id=906F000000092l6IAA

Does anyone have a better idea/code to deal with this problem?
 
I have some code that displays dynamic values in a selectlist

                <apex:pageBlock >
                    <apex:pageBlockTable value="{!Sample}" var="field" styleClass="table table-striped">
                        <apex:column value="{!Sample[field][0]}" headerValue="Salesforce Field"/>
                        <apex:column headerValue="CSV Field">
                             <apex:selectList value="{!Sample[field][1]}" styleClass="form-control" size="1">
                                 <apex:selectOptions value="{!csvField}"/>
                             </apex:selectList>
                         </apex:column>
                         <apex:column >
                         </apex:column>
                    </apex:pageBlockTable>
                </apex:pageBlock>

the problem is I want to remove the value that one selectlist has chosen
ex. options = Name, Gender, Age
I want to remove Name from other selectlist if one of the selectlist chooses it. It's my first time so I don't know how to do it.
The dynamic values in the selectlist are from an uploaded csv file.
I'm used to making test classes for inserting data in Objects but I'm kinda lost in making test data for this code...
(It retrieves the custom field names of my Custom Object mMovie__c)

public class objectlist {

  public List<string> fieldLabel {get;set;}
  
  public objectlist()
  {
    this.getAccountFields();
  }

  public void getAccountFields()
  {
          Map<String, Schema.SObjectType> gd = Schema.getGlobalDescribe();
          fieldLabel = new List<string>();      
          Map <String, Schema.SObjectField> fieldMap = gd.get('mMovie__c').getDescribe().fields.getMap();
          for(Schema.SObjectField fieldAPI : fieldMap.values())
          {     
              // if(fieldAPI.getDescribe().isCustom() )
              //{
               fieldLabel.add(fieldAPI.getDescribe().getLabel());
              //}
          }
          fieldLabel.sort();
          system.debug('fieldLabel-----'+fieldLabel);
  }     
}

 
here is my code...

public class objectlist {
    //Do not forget to get instance in constructor for this list
    //String type='Account';
     Map<String, Schema.SObjectType> gd = Schema.getGlobalDescribe();
       List<string> fieldLable = new List<string>();
        
       Map <String, Schema.SObjectField> fieldMap = gd.get('Account').getDescribe().fields.getMap();
       for(Schema.SObjectField fieldAPI : fieldMap.values())
       {
               fieldLable.add(+ '<' +fieldAPI.getDescribe().getName()+ '/>' );
       }
       
       system.debug('fieldLable-----'+fieldLable);
}

IDK what part is wrong...pls help me fix this...THX!!!
I encountered something like this through https://developer.salesforce.com/docs/atlas.en-us.lightning.meta/lightning/qs_aotp_app_step4_nested.htm
and I can't figure out how to save my form.cmp because I ddnt use any namespace on my developer account. I tried some ways but I can't seem to igure it out on my own and I don't have much experience with it. Any suggestions/solutions will be a great help to me...
I think I did everything listed in the challenge but I keep on getting this...

" Challenge not yet complete... here's what's wrong:
The process did not set the correct Type value on submitting for approval "


I already put an initial submission action:
-Field Update
-Object Account    
-Field to Update Account: Type
-Field Data Type Picklist
-a specific value: PENDING

i dont know what else to change...pls give me some ideas...routing records with approval process error

Hi,

 

I want to fetch the list of label names for all the fields of an Object....I got some code to get field labels of an Object 

 

i.e. <apex:column title=”{!$ObjectType.OpportunityLineItem.fields.Quantity.label}” headerValue=”{!$ObjectType.OpportunityLineItem.fields.Quantity.label}” width=”50px”>

 

But I want to get the list of all field labels by Apex..

I got the API name of all fields like this 

 

 String type='Account';

Map<String, Schema.SObjectType> schemaMap = Schema.getGlobalDescribe();
Schema.SObjectType leadSchema = schemaMap.get(type);
Map<String, Schema.SObjectField> fieldMap = leadSchema.getDescribe().fields.getMap();


for (String fieldName: fieldMap.keySet()) {

System.debug('##Field API Name='+fieldName);// list of all field API name
}

 

 

 

But I need to get the label name..

 

Please help

  • January 20, 2012
  • Like
  • 1