• Seraph
  • NEWBIE
  • 45 Points
  • Member since 2015

  • Chatter
    Feed
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 7
    Questions
  • 26
    Replies
Hi everyone...I made a class to be able to list records in a vf page table
global with sharing class Itemcls {
    @RemoteAction
    global static List<Item__c> getItems(){
        List<Item__c> itm = [SELECT Name,Id,Type__c from Item__c];
        System.debug(itm);
        return itm;
    }
 }

It worked as it should so I tried making a test class for it (based on pageblocktableadvance sample test class)
@isTest
private class Itemcls_Test{
    static testMethod void testItemcls(){
        Itemcls itm = new Itemcls();
        System.assertNotEquals(null,itm.getItems());
    }
}
I got an error
Error: Compile Error: Static methods cannot be invoked through an object instance: getItems() at line 5 column 37

Anyone have any suggestions as how to make a good/working test class for my apex class above?
I tried looking for it but most examples were not like mine and I haven't encountered making a class using RemoteAction before..
Good day!

 
I edited my class and saved it successfully but when I accessed my page which uses the class, I get an error of
DML currently not allowed
An unexpected error has occurred. Your development organization has been notified.

controller
public class DefinitionController {

    public DefinitionController() {
            this.DefTable();
    }

  public void DefTable(){
    listplatforms = [select Name,Status__c from Platform__c];

      for(Platform__c idlistplatforms : [select Id from Platform__c]){
        List<Def__c> existplatforms = [select Platform__c from Def__c where Platform__c=:idlistplatforms.Id];

            if(existplatforms.size() > 0)
            {
                idlistplatforms.Status__c = 'Set';
                //update idlistplatforms;
                System.debug('Found'+ idlistplatforms);
            } 
            else 
            {
                idlistplatforms.Status__c = 'Not Set';
                //update idlistplatforms;
                System.debug('Not Found'+ idlistplatforms);
            }
            update idlistplatforms;
      }
  }
    
}
I think the problem is because of the update part. How do I overcome this error?

Thanks in advance !

 
I have a table and a controller
<apex:page sidebar="false" controller="DisplayStatus">
          <apex:pageBlock title="Gadget (Gadget__c)">
             <apex:pageBlockTable value="{!gadgetlist}" var="gadget">
                 <apex:column headerValue="Gadget" value="{!gadget.Name}"/>
                 <apex:column headerValue="Action">
                       <apex:outputlink>Edit</apex:outputlink>
                 </apex:column>
             </apex:pageBlockTable>
         </apex:pageBlock> 
</apex>
If I click Edit it will return the value of its corresponding row (gadget.Name) in a System.debug.
ex.

Gadget                     Action

Smartphone               Edit
Watch                       Edit
Camera                     Edit

If I click Edit in the 2nd row, I would return Smartphone in a System.Debug statement.
How could I do this?

 
I have this visualforce page to show/explain my problem better
DisplayTable.page
I need a trigger (after insert,after update I think) to check if any record (from Item__c :Type__c) uses any of the values (from Gadget__c : Name) and if so it puts a value (at Gadget__c : Status) either Used or Unused like shown on the screenshot. It also changes if the value (from Item__c :Type__c) is changed which I think why the trigger must also be after update.

here is my working code:

visualforce page
<apex:page sidebar="false" controller="DisplayStatus">
   <apex:stylesheet value="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.5/css/bootstrap.min.css"/>
   <apex:includeScript value="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.5/js/bootstrap.min.js" />

   <div class="row">
       <div class="col-xs-6">
          <apex:pageBlock title="Gadget (Gadget__c)">
             <apex:pageBlockTable value="{!gadgetlist}" var="gadget">
                 <apex:column headerValue="Gadget Type (Name)" value="{!gadget.Name}"/>
                 <apex:column headerValue="Status (Status__c)" value="{!gadget.Status__c}"/>
             </apex:pageBlockTable>
         </apex:pageBlock>         
       </div>
       <div class="col-xs-6">
         <apex:pageBlock title="Item (Item__c)">
            <apex:pageBlockTable value="{!itemlist}" var="item">
               <apex:column headerValue="Item Name (Name)" value="{!item.Name}"/>
               <apex:column headerValue="Type (Lookup,Gadget__c)" value="{!item.Type__c}"/>
            </apex:pageBlockTable>
         </apex:pageBlock>         
       </div>
   </div>

</apex:page>

controller
public class DisplayStatus{
    public List<Gadget__c> gadgetlist {get; set;}
    public List<Item__c> itemlist {get; set;}

    public DisplayStatus()
    {
        this.ShowTable();
    }

    public void ShowTable()
    {
        gadgetlist = [select Name,Status__c from Gadget__c];
        itemlist = [select Name,Type__c from Item__c];
    }
}

It's a bit complicated for me so any help will be much appreciated.
Thanks!
Is it possible to change Month Key field value to month year format?

ex.
201503 => March 2015
201401 => January 2014

I need it for REPORTS (x-axis) because 201401 format doesn't look good but I don't know if it can be changed and how to do it?
THX...
I am currently following this link
http://www.forcetree.com/2010/08/read-and-insert-records-from-csv-file.html
and I tested it on my developer account. It worked great but when I tried to insert a large csv data (3000 rows) it had an error of regex too complicated. I know that the solution is by using batch apex http://developer.financialforce.com/customizations/importing-large-csv-files-via-batch-apex/ . the problem is I can't implement it on the forcetree code because I can't follow most of the explanation since I'm new in apex.
Can anyone pls share how to implement batch apex to the forcetree sample code? THX
I have a visualforce page(page 2) that displays results from another visualforce page(page 1)(values in the selectlist are from the inputs on a starting page)

Page 1 contains this
                <apex:pageBlock >
                    <apex:pageBlockTable value="{!objectField}" var="f">
                        <apex:column value="{!objectField[f][1]}" headerValue="SF Field"/>
                        <apex:column headerValue="Input Data">
                             <apex:selectList value="{!objectField[f][2]}" size="1">
                                 <apex:selectOptions value="{!input}"/>
                             </apex:selectList>
                         </apex:column>
                    </apex:pageBlockTable>
                </apex:pageBlock>
Page 2 is shows the result like this in a table (none is a value given when no data was inputted from page 1)

SF Field                  Input Data
Name                        Sam
Age                           18
Gender                       Male
Country                      none
Status                        none
Blood Type                  O
Job                             none

My problem is I only want to display in Page 2 those rows that have values (not none) like this

SF Field                  Input Data
Name                        Sam
Age                           18
Gender                       Male
Blood Type                  O

How do I do this?


 
I edited my class and saved it successfully but when I accessed my page which uses the class, I get an error of
DML currently not allowed
An unexpected error has occurred. Your development organization has been notified.

controller
public class DefinitionController {

    public DefinitionController() {
            this.DefTable();
    }

  public void DefTable(){
    listplatforms = [select Name,Status__c from Platform__c];

      for(Platform__c idlistplatforms : [select Id from Platform__c]){
        List<Def__c> existplatforms = [select Platform__c from Def__c where Platform__c=:idlistplatforms.Id];

            if(existplatforms.size() > 0)
            {
                idlistplatforms.Status__c = 'Set';
                //update idlistplatforms;
                System.debug('Found'+ idlistplatforms);
            } 
            else 
            {
                idlistplatforms.Status__c = 'Not Set';
                //update idlistplatforms;
                System.debug('Not Found'+ idlistplatforms);
            }
            update idlistplatforms;
      }
  }
    
}
I think the problem is because of the update part. How do I overcome this error?

Thanks in advance !

 
I have a table and a controller
<apex:page sidebar="false" controller="DisplayStatus">
          <apex:pageBlock title="Gadget (Gadget__c)">
             <apex:pageBlockTable value="{!gadgetlist}" var="gadget">
                 <apex:column headerValue="Gadget" value="{!gadget.Name}"/>
                 <apex:column headerValue="Action">
                       <apex:outputlink>Edit</apex:outputlink>
                 </apex:column>
             </apex:pageBlockTable>
         </apex:pageBlock> 
</apex>
If I click Edit it will return the value of its corresponding row (gadget.Name) in a System.debug.
ex.

Gadget                     Action

Smartphone               Edit
Watch                       Edit
Camera                     Edit

If I click Edit in the 2nd row, I would return Smartphone in a System.Debug statement.
How could I do this?

 
I have this visualforce page to show/explain my problem better
DisplayTable.page
I need a trigger (after insert,after update I think) to check if any record (from Item__c :Type__c) uses any of the values (from Gadget__c : Name) and if so it puts a value (at Gadget__c : Status) either Used or Unused like shown on the screenshot. It also changes if the value (from Item__c :Type__c) is changed which I think why the trigger must also be after update.

here is my working code:

visualforce page
<apex:page sidebar="false" controller="DisplayStatus">
   <apex:stylesheet value="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.5/css/bootstrap.min.css"/>
   <apex:includeScript value="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.5/js/bootstrap.min.js" />

   <div class="row">
       <div class="col-xs-6">
          <apex:pageBlock title="Gadget (Gadget__c)">
             <apex:pageBlockTable value="{!gadgetlist}" var="gadget">
                 <apex:column headerValue="Gadget Type (Name)" value="{!gadget.Name}"/>
                 <apex:column headerValue="Status (Status__c)" value="{!gadget.Status__c}"/>
             </apex:pageBlockTable>
         </apex:pageBlock>         
       </div>
       <div class="col-xs-6">
         <apex:pageBlock title="Item (Item__c)">
            <apex:pageBlockTable value="{!itemlist}" var="item">
               <apex:column headerValue="Item Name (Name)" value="{!item.Name}"/>
               <apex:column headerValue="Type (Lookup,Gadget__c)" value="{!item.Type__c}"/>
            </apex:pageBlockTable>
         </apex:pageBlock>         
       </div>
   </div>

</apex:page>

controller
public class DisplayStatus{
    public List<Gadget__c> gadgetlist {get; set;}
    public List<Item__c> itemlist {get; set;}

    public DisplayStatus()
    {
        this.ShowTable();
    }

    public void ShowTable()
    {
        gadgetlist = [select Name,Status__c from Gadget__c];
        itemlist = [select Name,Type__c from Item__c];
    }
}

It's a bit complicated for me so any help will be much appreciated.
Thanks!
Is it possible to change Month Key field value to month year format?

ex.
201503 => March 2015
201401 => January 2014

I need it for REPORTS (x-axis) because 201401 format doesn't look good but I don't know if it can be changed and how to do it?
THX...
I have a visualforce page(page 2) that displays results from another visualforce page(page 1)(values in the selectlist are from the inputs on a starting page)

Page 1 contains this
                <apex:pageBlock >
                    <apex:pageBlockTable value="{!objectField}" var="f">
                        <apex:column value="{!objectField[f][1]}" headerValue="SF Field"/>
                        <apex:column headerValue="Input Data">
                             <apex:selectList value="{!objectField[f][2]}" size="1">
                                 <apex:selectOptions value="{!input}"/>
                             </apex:selectList>
                         </apex:column>
                    </apex:pageBlockTable>
                </apex:pageBlock>
Page 2 is shows the result like this in a table (none is a value given when no data was inputted from page 1)

SF Field                  Input Data
Name                        Sam
Age                           18
Gender                       Male
Country                      none
Status                        none
Blood Type                  O
Job                             none

My problem is I only want to display in Page 2 those rows that have values (not none) like this

SF Field                  Input Data
Name                        Sam
Age                           18
Gender                       Male
Blood Type                  O

How do I do this?