• tantonio
  • NEWBIE
  • 20 Points
  • Member since 2012

  • Chatter
    Feed
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 12
    Questions
  • 18
    Replies
Hi All,

I am having trouble figuring out why this is method id failing. 

The row that is failing is when I try to add the values back into my list. 

Line: deletedChangeRecords.add(deletedChangeRecords[0]);

Error: There were custom validation error(s) encountered while saving the affected record(s). The first validation error encountered was "Apex trigger scv_tfs_marquee caused an unexpected exception, contact your administrator: scv_tfs_marquee: execution of BeforeDelete caused by: System.ListException: List index out of bounds: 0: Class.svc_tfs.MarqueeDelete: line 105, column 1".

I think this has something to do with the fact that this method is called by a before delete trigger. Functionally, this method is supposed to update a record on a different object (ChangeRecord__c) before the delete occurs. 

Thanks for any help on with this!


public static void MarqueeDelete(List<NI_MarqueeFeature__c> marqueeDelete){ 
        
            List <ChangeRecord__c> deletedChangeRecords = new List <ChangeRecord__c>();

        	for (NI_MarqueeFeature__c md : marqueeDelete){//deletedChangeRecords contains trigger.new
            List <ChangeRecord__c>  deletedChangeRecord  = [SELECT ID, LastMod__c FROM ChangeRecord__c WHERE ChangeRecord__c.ID__c = :md.Id LIMIT 1];           
            	
            	//If now matching change record is found, create one
            	//else update the existing one
            	if (deletedChangeRecord.size()<1){
                    ChangeRecord__c dm = new ChangeRecord__c ();

                        dm.ID__c = md.id;
                        dm.ObjectType__c = 0; //0 for Marquee Feature, 1 for CR, 2 for Product Release
                    	dm.type__c = 2;
                        deletedChangeRecord.add(dm);
                        
                        try {
                            insert dm;
                          } catch (system.DmlException e) {
                            system.debug (e);}
                                                
                } else {
            			//Setting the value of LastModd__c to the last mod of trigger.new
                        deletedChangeRecord[0].LastMod__c = md.LastModifiedDate;
                    	deletedChangeRecord[0].type__c = 2;
                    try {
                        deletedChangeRecords.add(deletedChangeRecords[0]);
            		}  catch (system.DmlException e) {
                        system.debug (e);}
        }  
     }


I am trying to figure out how to pass the ID of an existing record I am trying to update. I get the above error in the debug logs after running this method.

As a background, I have a trigger after update running the passes trigger.new into a method called MarqueeUpdate. From there, I query to find the existing ChangeRecord__c. I need the ID of that ChangeRecord__c to update. 

I cannot figure out how to pass the id of that record to my update statement. 
//Updating existing records
    public static void MarqueeUpdate(List<NI_MarqueeFeature__c> marqueeUpdate){ 
        
        //marqueeUpdate contains trigger.new
        for (NI_MarqueeFeature__c mi : marqueeUpdate){
            String Id = mi.Id;
            List <ChangeRecord__c>  upMarquee = [SELECT ID
                    				 FROM ChangeRecord__c
                				 WHERE ChangeRecord__c.ID__c = :Id];
            
                    if (marqueeUpdate.size()>0) {
                        ChangeRecord__c um = new ChangeRecord__c ();
                        
                        um.ID__c = mi.id;
                        um.LastMod__c = mi.LastModifiedDate;
                        
                        upMarquee.add(um);
                        
                        try {
                            update um;
                          } catch (system.DmlException e) {
                            system.debug (e);}
        }
        }
    }


Below button opens in a separate tab. Originally this is the functionality I wanted but now I need to change to have it open in the existing page. 

How can I do this?

<apex:column >
                   <apex:commandButton onclick="return window.open('{!obj.LoginURL__c}')" value="Login" >
                       <Apex:outputLink value="{!obj.LoginURL__c}"/>
                   </apex:commandbutton>
               </apex:column>
I have made a VF tab mobile ready. When I go to "Mobile Administration | Mobile Navigation" in setup, the tab isn't showing to add to the mobile navigation menu items.

Why??

I have a functioning controller class with a simple page block visualforce page on top. Although it is functioning I don't believe its very well written yet. I want to mature it and make sure its formed as best it can be without extending the funcitonality. 

 

Can you make some suggestions of what I could do to improve and why it would benefit the class? Thanks!!!

 

Controller Class:

 

Public class listorgs  implements iterator<org__c>{
        public List<org__c> newlist {get; set;}
        public List<org__c> deplist {get; set;}
    	public List<org__c> devlist {get; set;}
        Integer i {get; set;}

        public listorgs(){
            newlist = [select id, name , LoginURL__c, LoginURLs__c , HRM_Installed__c, Description__c , Type__c, 
                       Pod__c, org_id__c, Version_Password__c, Deprecated__c, IELink__c, PW__c, CreatedDate
                       from org__c where Deprecated__c != True and Type__c!='Dev Org'
                       order by type__c asc];
            
            devlist = [select id, name , LoginURL__c , LoginURLs__c, HRM_Installed__c, Description__c , Type__c, 
                       Pod__c, org_id__c, Version_Password__c, Deprecated__c, IELink__c, PW__c, CreatedDate
                       from org__c where Deprecated__c != True and Type__c='Dev Org'
                       order by type__c asc];
            
            deplist = [select id, name , LoginURL__c , LoginURLs__c, HRM_Installed__c, Description__c , Type__c, 
                       Pod__c, org_id__c, Version_Password__c, Deprecated__c, IELink__c
                       from org__c where Deprecated__c = True
                       order by type__c asc];
            i = 0;
                
        }
        Public boolean hasnext(){
            if(i>= newlist.size()){
                return false;
            } else {
                return true;
            }
        }
        Public Org__c next(){
            if(i==100){return null;}
            i++;
            return newlist[i-1];
        }

     //save button
            public pagereference save() { 
            update newlist; 
            update devlist;
            update deplist;
            return null; 
        }
    //New button
    public PageReference newrecord (){
        PageReference pr;
        pr = new pagereference ('https://na14.salesforce.com/a0R/e?retURL=%2Fa0R%2Fo');
        pr.setredirect(true);
        return pr;
    }
}

 

VF Page:

<apex:page controller="listorgs" sidebar="false">

    <apex:form >
    
        <Apex:pageblock >
          <apex:pageblockButtons >
            <apex:commandButton action="{!Save}" value="Save"/>


            <apex:commandButton action="{!newrecord}" value="New"/>
            </apex:pageblockButtons><apex:inlineEditSupport />
        <br/>
        <br/>
            
            <apex:pageblockTable value="{!newlist}" var="obj">
           
               <apex:column >
                   <apex:commandButton onclick="window.open('{!obj.LoginURL__c}')" value="Login" reRender="loginhome">
                       <Apex:outputLink value="{!obj.LoginURL__c}"/>
                   </apex:commandbutton>
               </apex:column>
                
                
               <apex:column headerValue="Username">
                    <apex:commandLink onclick="window.open('{'!obj.name'}')"  reRender="loginhome">
                        <apex:outputLink value="/{!obj.id}">{!obj.name}
                        </apex:outputLink>
                    </apex:commandLink>
               </apex:column>
                                
                <apex:column headerValue="CopyLink" style="width:10px">
                    <apex:outputField style="width:10px" value="{!obj.LoginURLs__c}"/>
                </apex:column>
                        
                <apex:column headerValue="PW" style="width:10px">
                    <apex:outputField style="width:10px" value="{!obj.PW__c}"/>
                </apex:column>
                
                <apex:column headerValue="Type" >
                    <Apex:outputfield value="{!obj.Type__c}"/>
                    
                </apex:column>
                
                <apex:column headerValue="Description">
                    <Apex:outputfield value="{!obj.Description__c}"/>
                
                </apex:column>
                
                <apex:column headerValue="Org ID">
                    <Apex:outputfield value="{!obj.Org_ID__c}"/>
                    
                </apex:column>
                
                <apex:column headerValue="Instance">
                    <Apex:outputfield value="{!obj.POD__c}"/>
                    
                </apex:column>    
                    
                
                <apex:column headerValue="Package Version">
                    <Apex:outputfield value="{!obj.Version_Password__c}"/>
                    
                </apex:column>
                
                <apex:column headerValue="Deprecated">
                    <Apex:outputfield value="{!obj.Deprecated__c}"/>
                    
                </apex:column>
                
                <apex:column headerValue="Created">
                    <Apex:outputfield value="{!obj.CreatedDate}"/>
                    
                </apex:column>
                
            </apex:pageblockTable>
            
            
            
            <apex:pageblockTable value="{!devlist}" var="obj">
           
               <apex:column >
                   <apex:commandButton onclick="window.open('{!obj.LoginURL__c}')" value="Login" reRender="loginhome">
                       <Apex:outputLink value="{!obj.LoginURL__c}"/>
                   </apex:commandbutton>
               </apex:column>
                
                
               <apex:column headerValue="Username">
                    <apex:commandLink onclick="window.open('{'!obj.name'}')"  reRender="loginhome">
                        <apex:outputLink value="/{!obj.id}">{!obj.name}
                        </apex:outputLink>
                    </apex:commandLink>
               </apex:column>
                                
                <apex:column headerValue="CopyLink" style="width:10px">
                    <apex:outputField style="width:10px" value="{!obj.LoginURLs__c}"/>
                </apex:column>
                        
                <apex:column headerValue="PW" style="width:10px">
                    <apex:outputField style="width:10px" value="{!obj.PW__c}"/>
                </apex:column>
                
                <apex:column headerValue="Type" >
                    <Apex:outputfield value="{!obj.Type__c}"/>
                    
                </apex:column>
                
                <apex:column headerValue="Description">
                    <Apex:outputfield value="{!obj.Description__c}"/>
                
                </apex:column>
                
                <apex:column headerValue="Org ID">
                    <Apex:outputfield value="{!obj.Org_ID__c}"/>
                    
                </apex:column>
                
                <apex:column headerValue="Instance">
                    <Apex:outputfield value="{!obj.POD__c}"/>
                    
                </apex:column>    
                    
                
                <apex:column headerValue="Package Version">
                    <Apex:outputfield value="{!obj.Version_Password__c}"/>
                    
                </apex:column>
                
                <apex:column headerValue="Deprecated">
                    <Apex:outputfield value="{!obj.Deprecated__c}"/>
                    
                </apex:column>
                
                <apex:column headerValue="Created">
                    <Apex:outputfield value="{!obj.CreatedDate}"/>
                    
                </apex:column>
                
            </apex:pageblockTable>
            
            
            
            <apex:pageBlockTable value="{!deplist}" var="obj">
            
            <apex:column >
                   <apex:commandButton onclick="window.open('{!obj.LoginURL__c}')" value="Login" reRender="loginhome">
                       <Apex:outputLink value="{!obj.LoginURL__c}"/>
                   </apex:commandbutton>
               </apex:column>
                
               <apex:column headerValue="Username">
                    <apex:commandLink onclick="window.open('{'!obj.name'}')"  reRender="loginhome">
                        <apex:outputLink value="/{!obj.id}">{!obj.name}
                        </apex:outputLink>
                    </apex:commandLink>
               </apex:column>
                        
                
               <!-- <apex:column headerValue="Username" >
                    <apex:outputLink value="{!obj.id}">{!obj.name}</apex:outputLink>
                    
                </apex:column>
                -->
                
                <apex:column headerValue="Type" >
                    <Apex:outputfield value="{!obj.Type__c}"/>
                    
                </apex:column>
                
                <apex:column headerValue="Description">
                    <Apex:outputfield value="{!obj.Description__c}"/>
                
                </apex:column>
                
                <apex:column headerValue="Org ID">
                    <Apex:outputfield value="{!obj.Org_ID__c}"/>
                    
                </apex:column>
                
                <apex:column headerValue="POD">
                    <Apex:outputfield value="{!obj.POD__c}"/>
                    
                </apex:column>    
                    
                
                <apex:column headerValue="Package Version">
                    <Apex:outputfield value="{!obj.Version_Password__c}"/>
                    
                </apex:column>
                
                <apex:column headerValue="Deprecated">
                    <Apex:outputfield value="{!obj.Deprecated__c}"/>
                    
                </apex:column>
                

            
            </apex:pageBlockTable>
        
        
        
        
        
        </Apex:pageblock>
        
    </apex:form>
    
</apex:page>

 

Test Class:

@IsTest
public class TestListorgs{
            static testmethod void testorg(){
        
        //created org__c record
        org__c org1 = new org__c (Name = 'unit test 1',
                                  pw__c = 'password',
                                  Deprecated__c = true);
        insert org1;
        
        //check that the inserted record has correct name
        system.assertequals('unit test 1',org1.name);
        system.assertequals('password',org1.pw__c);
        system.assertequals(True,org1.Deprecated__c);
                

        //Creating i
        integer i=0;
        
        test.starttest();
            //instantiate controller
            listorgs lo = new listorgs();
            lo.hasnext();
                    //Confirm hasnext boolean is true
                    system.assertequals(lo.hasnext(),True);
                    
                   // system.assertequals(lo.next(),lo.hasnext());
            
            //confirm save returns null
       	    system.assertequals(lo.save(),null);
            
            
        	//test next method
            system.assertequals(lo.next(),lo.newlist[i++]);
        test.stoptest();
        
    }           
}

 

 

I am looking to make one column in my pageblocktable less wide then all the others. It should be really slim, maybe like 10 or 20 px wide. All other columns should continue to auto adjust their own widths.

 

Is there any way to do this within a pageblocktable?

 

I am trying to make this column less wide. Currently the style I have added does absolutely nothing in runtime:

 

                <apex:column headerValue="CopyLink" style="width:10px">
                    <apex:outputField style="width:10px" value="{!obj.LoginURL__c}"/>
                </apex:column>
                        

 

 

Full VF below:

 

<apex:page controller="listorgs" sidebar="false">

    <apex:form >
    
        <Apex:pageblock >
          <apex:pageblockButtons >
            <apex:commandButton action="{!Save}" value="Save"/>


            <apex:commandButton action="{!newrecord}" value="New"/>
            </apex:pageblockButtons><apex:inlineEditSupport />
        <br/>
        <br/>
            
            <apex:pageblockTable value="{!newlist}" var="obj">
           
               <apex:column >
                   <apex:commandButton onclick="window.open('{!obj.LoginURL__c}')" value="Login" reRender="loginhome">
                       <Apex:outputLink value="{!obj.LoginURL__c}"/>
                   </apex:commandbutton>
               </apex:column>
                
                
               <apex:column headerValue="Username">
                    <apex:commandLink onclick="window.open('{'!obj.name'}')"  reRender="loginhome">
                        <apex:outputLink value="/{!obj.id}">{!obj.name}
                        </apex:outputLink>
                    </apex:commandLink>
               </apex:column>
                                
                <apex:column headerValue="CopyLink" style="width:10px">
                    <apex:outputField style="width:10px" value="{!obj.LoginURL__c}"/>
                </apex:column>
                        
                
               <!-- <apex:column headerValue="Username" >
                    <apex:outputLink value="{!obj.id}">{!obj.name}</apex:outputLink>
                    
                </apex:column>
                ^^^Removed because this was made into the command link above-->
                
                <apex:column headerValue="Type" >
                    <Apex:outputfield value="{!obj.Type__c}"/>
                    
                </apex:column>
                
                <apex:column headerValue="Description">
                    <Apex:outputfield value="{!obj.Description__c}"/>
                
                </apex:column>
                
                <apex:column headerValue="Org ID">
                    <Apex:outputfield value="{!obj.Org_ID__c}"/>
                    
                </apex:column>
                
                <apex:column headerValue="POD">
                    <Apex:outputfield value="{!obj.POD__c}"/>
                    
                </apex:column>    
                    
                
                <apex:column headerValue="Package Version">
                    <Apex:outputfield value="{!obj.Version_Password__c}"/>
                    
                </apex:column>
                
                <apex:column headerValue="Deprecated">
                    <Apex:outputfield value="{!obj.Deprecated__c}"/>
                    
                </apex:column>
                
            </apex:pageblockTable>
            
            <apex:pageBlockTable value="{!deplist}" var="obj">
            
            <apex:column >
                   <apex:commandButton onclick="window.open('{!obj.LoginURL__c}')" value="Login" reRender="loginhome">
                       <Apex:outputLink value="{!obj.LoginURL__c}"/>
                   </apex:commandbutton>
               </apex:column>
                
               <apex:column headerValue="Username">
                    <apex:commandLink onclick="window.open('{'!obj.name'}')"  reRender="loginhome">
                        <apex:outputLink value="/{!obj.id}">{!obj.name}
                        </apex:outputLink>
                    </apex:commandLink>
               </apex:column>
                        
                
               <!-- <apex:column headerValue="Username" >
                    <apex:outputLink value="{!obj.id}">{!obj.name}</apex:outputLink>
                    
                </apex:column>
                -->
                
                <apex:column headerValue="Type" >
                    <Apex:outputfield value="{!obj.Type__c}"/>
                    
                </apex:column>
                
                <apex:column headerValue="Description">
                    <Apex:outputfield value="{!obj.Description__c}"/>
                
                </apex:column>
                
                <apex:column headerValue="Org ID">
                    <Apex:outputfield value="{!obj.Org_ID__c}"/>
                    
                </apex:column>
                
                <apex:column headerValue="POD">
                    <Apex:outputfield value="{!obj.POD__c}"/>
                    
                </apex:column>    
                    
                
                <apex:column headerValue="Package Version">
                    <Apex:outputfield value="{!obj.Version_Password__c}"/>
                    
                </apex:column>
                
                <apex:column headerValue="Deprecated">
                    <Apex:outputfield value="{!obj.Deprecated__c}"/>
                    
                </apex:column>
                

            
            </apex:pageBlockTable>
        
        
        
        
        
        </Apex:pageblock>
        
    </apex:form>
    
</apex:page>

 

I suspect the answer to this question is no, there's no easy way to do this.

 

I have a page which has outputlink buttons. I run this page in Chrome however I want to take this 1 single button and change it into say 3 different buttons to open the link in three separate browsers. This way I can easily choose which browser I want to launch the link in.

 

I believe I would have to do something with program files on Windows if I wanted to make this type of functionality happen. Is there a way around that?

 

Any ideas are welcome. Thanks!

Hello All,

 

I need help figuring out why this test class is failing. Thanks for the help!!!

 

Error:

Class	listorgtest
Method Name	testorg
Pass/Fail	Fail
Error Message	System.NullPointerException: Attempt to de-reference a null object
Stack Trace	Class.listorgtest.testorg: line 13, column 1

 Test Class:

@istest
public class listorgtest{
    public static testmethod void testorg(){
        
        //instantiage a page
        pagereference pageref = page.loginhome;
        test.setcurrentpage(pageref);
        
        //construct controller class
        listorgs lo = new listorgs();
        
        //getting url of login
        string savepage = lo.save().geturl();
        
        //checking login url
        system.assertequals('apex/LoginHome?sfdc.tabName=01rd00000007LkS', savepage);
	}
}

 Controller class:

Public class listorgs  implements iterator<org__c>{
        public List<org__c> newlist {get; set;}
        Integer i {get; set;}
        public ApexPages.StandardController listorgs {get; set;}
        public listorgs(ApexPages.StandardController controller) {
            listorgs = controller;}

        
        public listorgs(){
            newlist = [select id, name , LoginURL__c , HRM_Installed__c, Description__c , Type__c, 
                       Pod__c, org_id__c, Version_Password__c, Deprecated__c
                       from org__c order by type__c asc];
            i = 0;
                }
        Public boolean hasnext(){
            if(i>= newlist.size()){
                return false;
            } else {
                return true;
            }
        }
        Public Org__c next(){
            if(i==100){return null;}
            i++;
            return newlist[i-1];
        }
        public string page{get;set;}
        public string openpageurl {get;set;}
                
        public void onload()
        {
            page = '';
            openpageurl = '';
        }
        //Below code is not being used for login functionality.
        //public pagereference redirect()
      //  {
          // if( page == 'login')
          //  {
          //      openpageurl = 'http://google.com';
          //  }
         //   return null;
      //  }
   	 //save button
            public pagereference save() { 
            update newlist; 
            return null; 
        }       

}

 

Below is a class that has a list of all records in an object within a pageblocktable. Inline edits are enabled so I can update the records from this table if I like. I am trying to get a save button functioning that will save the entire list when I click it.

 

Right now when I click save, the data dissapears and does not persist. Please help!

 

Controller Class:

Public class listorgs  implements iterator<org__c>{
        public static List<org__c> newlist {get; set;}
        Integer i {get; set;}
        public ApexPages.StandardController listorgs {get; set;}
        public listorgs(ApexPages.StandardController controller) {
            listorgs = controller;}

        
        public listorgs(){
            newlist = [select id, name , LoginURL__c , HRM_Installed__c, Description__c , Type__c, Pod__c, org_id__c
                       from org__c order by type__c asc];
            i = 0;
                }
        Public boolean hasnext(){
            if(i>= newlist.size()){
                return false;
            } else {
                return true;
            }
        }
        Public Org__c next(){
            if(i==100){return null;}
            i++;
            return newlist[i-1];
        }
        public string page{get;set;}
        public string openpageurl {get;set;}
                
        public void onload()
        {
            page = '';
            openpageurl = '';
        }
        
        public pagereference redirect()
        {
           if( page == 'login')
            {
                openpageurl = 'http://google.com';
            }
            return null;
        }
    public pagereference save(){
                    newlist = [select id, name , LoginURL__c , HRM_Installed__c, Description__c , Type__c, Pod__c, org_id__c
                       from org__c order  by type__c asc ];
            update newlist;
            return null;
            
        }
            
}

 Visualforce page:

<apex:page controller="listorgs" sidebar="false">

    <apex:form >
    
        <Apex:pageblock >
          <apex:pageblockButtons >
            <apex:commandButton action="{!Save}" value="Save"/>
            </apex:pageblockButtons><apex:inlineEditSupport />
        <br/>
        <br/>
            
            <apex:pageblockTable value="{!newlist}" var="obj">
           
               <apex:column >
                   <apex:commandButton onclick="window.open('{!obj.LoginURL__c}')" value="Login" reRender="loginhome">
                       <Apex:outputLink value="{!obj.LoginURL__c}"/>
                   </apex:commandbutton>
               </apex:column>
                
                    

                
                <apex:column headerValue="Username" >
                    <Apex:outputfield value="{!obj.name}"/>
                    
                </apex:column>
                
                <apex:column headerValue="Type" >
                    <Apex:outputfield value="{!obj.Type__c}"/>
                    
                </apex:column>
                
                <apex:column headerValue="Description">
                    <Apex:outputfield value="{!obj.Description__c}"/>
                
                </apex:column>
                
                <apex:column headerValue="Org ID">
                    <Apex:outputfield value="{!obj.Org_ID__c}"/>
                    
                </apex:column>
                
                <apex:column headerValue="POD">
                    <Apex:outputfield value="{!obj.POD__c}"/>
                    
                </apex:column>    
                    
                
                <apex:column headerValue="HRM Installed?">
                    <Apex:outputfield value="{!obj.HRM_Installed__c}"/>
                    
                </apex:column>
                
            </apex:pageblockTable>
        </Apex:pageblock>
        
    </apex:form>
    
</apex:page>

 Thanks for the help!!

Hello!

 

I am looking to add a button to each row in my pageblocktable and the button should call the value of the URL field called loginURL__c. Basically I'm trying to take the column in my pageblock which is a field value and make it a button. I'm having trouble even getting started with this one. All the only resources only show how to add a button to the top of a pageblocktable, which I've done and its not what I'm looking for.

 

Can anybody help me get going in the right direction?

 

VFP:

 

<apex:page controller="listorgs">

    <apex:form >
    
        <Apex:pageblock >
          <Apex:pageblockButtons >
                        <Apex:commandButton value="login" onclick="openpage('login'); return false;"/>
                        </Apex:pageblockButtons>
        <br/>
        <br/>
            
            <apex:pageblockTable value="{!newlist}" var="obj">
                
                <apex:column >
                    <Apex:outputfield value="{!obj.name}"/>
                    
                </apex:column>
                
                <apex:column >
                    <Apex:outputfield value="{!obj.LoginURL__c}"/>
                    
                </apex:column>
                
                <apex:column >
                    <Apex:outputfield value="{!obj.Description__c}"/>
                    
                </apex:column>
                
                <apex:column >
                    <Apex:outputfield value="{!obj.HRM_Installed__c}"/>
                    
                </apex:column>
                
            </apex:pageblockTable>
        </Apex:pageblock>
        
    </apex:form>
    
</apex:page>

 

Controlling Class:

 

Public class listorgs
    implements iterator<org__c>{
        public static List<org__c> newlist {get; set;}
        Integer i {get; set;}
        
        public listorgs(){
            newlist = [select id, name , LoginURL__c , HRM_Installed__c, Description__c from org__c];
            i = 0;
                }
        Public boolean hasnext(){
            if(i>= newlist.size()){
                return false;
            } else {
                return true;
            }
        }
        Public Org__c next(){
            if(i==100){return null;}
            i++;
            return newlist[i-1];
        }
        public string page{get;set;}
        public string openpageurl {get;set;}
		
        public void onload()
        {
            page = '';
            openpageurl = '';
        }
        
        public pagereference redirect()
        {
           if( page == 'login')
            {
                openpageurl = 'http://google.com';
            }
            return null;
        }
}

    

 

Thanks for the tips!!!

I am getting this error "value for <apex:outputField> is not a dynamic binding!" on my VFP and not sure why. I read somewhere on forumns that this can be caused potentially by multi-currency being enabled, which I do have on but I'm not 100% sure that has anything to do with it.

 

VFP:

 

<apex:page controller="listorgs">

    <apex:form >
    
        <Apex:pageblock >

            <apex:pageblockTable value="{!newlist}" var="obj">
                <apex:column >
                    <Apex:outputfield value="obj.name"/>
                </apex:column>
            </apex:pageblockTable>
        </Apex:pageblock>
        
    </apex:form>
    
</apex:page>

 

Controlling class:

 

Public class listorgs
    implements iterator<org__c>{
        public static List<org__c> newlist {get; set;}
        Integer i {get; set;}
        
        public listorgs(){
            newlist = [select id, name from org__c];
            i = 0;
                }
        Public boolean hasnext(){
            if(i>= newlist.size()){
                return false;
            } else {
                return true;
            }
        }
        Public Org__c next(){
            if(i==100){return null;}
            i++;
            return newlist[i-1];
        }
}

    

 

Thanks to anyone who can help!

 

Hello, I am very new to writing both VF and Apex. I know this question is rudementary but I'm still struggling with getting the below solution to work. 

 

I am looking to create a visualforce page that will display all the records within a custom object I built, Org__c.

 

Below is the class I built to gather the data and pass into the pageblocktable. I'm assuming I have some extra code here that I could probably get rid of, as a side note. 

 

Global class listorgs
    implements iterator<org__c>{
        List<org__c> newlist {get; set;}
        Integer i {get; set;}
        
        public listorgs(){
            newlist = [select id, name from org__c];
            i = 0;
                }
        Global boolean hasnext(){
            if(i>= newlist.size()){
                return false;
            } else {
                return true;
            }
        }
        Global Org__c next(){
            if(i==100){return null;}
            i++;
            return newlist[i-1];
        }
}

    

 And here is the VFP. Note that I don't necessaryly have a variable called "name" but I just don't know what to put there. Any tips on that would be helpful as well as letting me know whats causing my VF to not be able to find the wrapper apex above.

 

<apex:page>

    <apex:form >
    
        <Apex:pageblock >
        <br/>
        <br/>
            <apex:commandButton value="Add Row" action="{!addrecord}" />
            
            <apex:pageblockTable value="{!listorgs}" var="name">
            
            </apex:pageblockTable>
        </Apex:pageblock>
        
    </apex:form>
    
</apex:page>

 

Thanks ahead of time for anyone who's willing to help!!

Hi All,

I am having trouble figuring out why this is method id failing. 

The row that is failing is when I try to add the values back into my list. 

Line: deletedChangeRecords.add(deletedChangeRecords[0]);

Error: There were custom validation error(s) encountered while saving the affected record(s). The first validation error encountered was "Apex trigger scv_tfs_marquee caused an unexpected exception, contact your administrator: scv_tfs_marquee: execution of BeforeDelete caused by: System.ListException: List index out of bounds: 0: Class.svc_tfs.MarqueeDelete: line 105, column 1".

I think this has something to do with the fact that this method is called by a before delete trigger. Functionally, this method is supposed to update a record on a different object (ChangeRecord__c) before the delete occurs. 

Thanks for any help on with this!


public static void MarqueeDelete(List<NI_MarqueeFeature__c> marqueeDelete){ 
        
            List <ChangeRecord__c> deletedChangeRecords = new List <ChangeRecord__c>();

        	for (NI_MarqueeFeature__c md : marqueeDelete){//deletedChangeRecords contains trigger.new
            List <ChangeRecord__c>  deletedChangeRecord  = [SELECT ID, LastMod__c FROM ChangeRecord__c WHERE ChangeRecord__c.ID__c = :md.Id LIMIT 1];           
            	
            	//If now matching change record is found, create one
            	//else update the existing one
            	if (deletedChangeRecord.size()<1){
                    ChangeRecord__c dm = new ChangeRecord__c ();

                        dm.ID__c = md.id;
                        dm.ObjectType__c = 0; //0 for Marquee Feature, 1 for CR, 2 for Product Release
                    	dm.type__c = 2;
                        deletedChangeRecord.add(dm);
                        
                        try {
                            insert dm;
                          } catch (system.DmlException e) {
                            system.debug (e);}
                                                
                } else {
            			//Setting the value of LastModd__c to the last mod of trigger.new
                        deletedChangeRecord[0].LastMod__c = md.LastModifiedDate;
                    	deletedChangeRecord[0].type__c = 2;
                    try {
                        deletedChangeRecords.add(deletedChangeRecords[0]);
            		}  catch (system.DmlException e) {
                        system.debug (e);}
        }  
     }


I am trying to figure out how to pass the ID of an existing record I am trying to update. I get the above error in the debug logs after running this method.

As a background, I have a trigger after update running the passes trigger.new into a method called MarqueeUpdate. From there, I query to find the existing ChangeRecord__c. I need the ID of that ChangeRecord__c to update. 

I cannot figure out how to pass the id of that record to my update statement. 
//Updating existing records
    public static void MarqueeUpdate(List<NI_MarqueeFeature__c> marqueeUpdate){ 
        
        //marqueeUpdate contains trigger.new
        for (NI_MarqueeFeature__c mi : marqueeUpdate){
            String Id = mi.Id;
            List <ChangeRecord__c>  upMarquee = [SELECT ID
                    				 FROM ChangeRecord__c
                				 WHERE ChangeRecord__c.ID__c = :Id];
            
                    if (marqueeUpdate.size()>0) {
                        ChangeRecord__c um = new ChangeRecord__c ();
                        
                        um.ID__c = mi.id;
                        um.LastMod__c = mi.LastModifiedDate;
                        
                        upMarquee.add(um);
                        
                        try {
                            update um;
                          } catch (system.DmlException e) {
                            system.debug (e);}
        }
        }
    }


Below button opens in a separate tab. Originally this is the functionality I wanted but now I need to change to have it open in the existing page. 

How can I do this?

<apex:column >
                   <apex:commandButton onclick="return window.open('{!obj.LoginURL__c}')" value="Login" >
                       <Apex:outputLink value="{!obj.LoginURL__c}"/>
                   </apex:commandbutton>
               </apex:column>
I have made a VF tab mobile ready. When I go to "Mobile Administration | Mobile Navigation" in setup, the tab isn't showing to add to the mobile navigation menu items.

Why??

Hello All,

 

I need help figuring out why this test class is failing. Thanks for the help!!!

 

Error:

Class	listorgtest
Method Name	testorg
Pass/Fail	Fail
Error Message	System.NullPointerException: Attempt to de-reference a null object
Stack Trace	Class.listorgtest.testorg: line 13, column 1

 Test Class:

@istest
public class listorgtest{
    public static testmethod void testorg(){
        
        //instantiage a page
        pagereference pageref = page.loginhome;
        test.setcurrentpage(pageref);
        
        //construct controller class
        listorgs lo = new listorgs();
        
        //getting url of login
        string savepage = lo.save().geturl();
        
        //checking login url
        system.assertequals('apex/LoginHome?sfdc.tabName=01rd00000007LkS', savepage);
	}
}

 Controller class:

Public class listorgs  implements iterator<org__c>{
        public List<org__c> newlist {get; set;}
        Integer i {get; set;}
        public ApexPages.StandardController listorgs {get; set;}
        public listorgs(ApexPages.StandardController controller) {
            listorgs = controller;}

        
        public listorgs(){
            newlist = [select id, name , LoginURL__c , HRM_Installed__c, Description__c , Type__c, 
                       Pod__c, org_id__c, Version_Password__c, Deprecated__c
                       from org__c order by type__c asc];
            i = 0;
                }
        Public boolean hasnext(){
            if(i>= newlist.size()){
                return false;
            } else {
                return true;
            }
        }
        Public Org__c next(){
            if(i==100){return null;}
            i++;
            return newlist[i-1];
        }
        public string page{get;set;}
        public string openpageurl {get;set;}
                
        public void onload()
        {
            page = '';
            openpageurl = '';
        }
        //Below code is not being used for login functionality.
        //public pagereference redirect()
      //  {
          // if( page == 'login')
          //  {
          //      openpageurl = 'http://google.com';
          //  }
         //   return null;
      //  }
   	 //save button
            public pagereference save() { 
            update newlist; 
            return null; 
        }       

}

 

Below is a class that has a list of all records in an object within a pageblocktable. Inline edits are enabled so I can update the records from this table if I like. I am trying to get a save button functioning that will save the entire list when I click it.

 

Right now when I click save, the data dissapears and does not persist. Please help!

 

Controller Class:

Public class listorgs  implements iterator<org__c>{
        public static List<org__c> newlist {get; set;}
        Integer i {get; set;}
        public ApexPages.StandardController listorgs {get; set;}
        public listorgs(ApexPages.StandardController controller) {
            listorgs = controller;}

        
        public listorgs(){
            newlist = [select id, name , LoginURL__c , HRM_Installed__c, Description__c , Type__c, Pod__c, org_id__c
                       from org__c order by type__c asc];
            i = 0;
                }
        Public boolean hasnext(){
            if(i>= newlist.size()){
                return false;
            } else {
                return true;
            }
        }
        Public Org__c next(){
            if(i==100){return null;}
            i++;
            return newlist[i-1];
        }
        public string page{get;set;}
        public string openpageurl {get;set;}
                
        public void onload()
        {
            page = '';
            openpageurl = '';
        }
        
        public pagereference redirect()
        {
           if( page == 'login')
            {
                openpageurl = 'http://google.com';
            }
            return null;
        }
    public pagereference save(){
                    newlist = [select id, name , LoginURL__c , HRM_Installed__c, Description__c , Type__c, Pod__c, org_id__c
                       from org__c order  by type__c asc ];
            update newlist;
            return null;
            
        }
            
}

 Visualforce page:

<apex:page controller="listorgs" sidebar="false">

    <apex:form >
    
        <Apex:pageblock >
          <apex:pageblockButtons >
            <apex:commandButton action="{!Save}" value="Save"/>
            </apex:pageblockButtons><apex:inlineEditSupport />
        <br/>
        <br/>
            
            <apex:pageblockTable value="{!newlist}" var="obj">
           
               <apex:column >
                   <apex:commandButton onclick="window.open('{!obj.LoginURL__c}')" value="Login" reRender="loginhome">
                       <Apex:outputLink value="{!obj.LoginURL__c}"/>
                   </apex:commandbutton>
               </apex:column>
                
                    

                
                <apex:column headerValue="Username" >
                    <Apex:outputfield value="{!obj.name}"/>
                    
                </apex:column>
                
                <apex:column headerValue="Type" >
                    <Apex:outputfield value="{!obj.Type__c}"/>
                    
                </apex:column>
                
                <apex:column headerValue="Description">
                    <Apex:outputfield value="{!obj.Description__c}"/>
                
                </apex:column>
                
                <apex:column headerValue="Org ID">
                    <Apex:outputfield value="{!obj.Org_ID__c}"/>
                    
                </apex:column>
                
                <apex:column headerValue="POD">
                    <Apex:outputfield value="{!obj.POD__c}"/>
                    
                </apex:column>    
                    
                
                <apex:column headerValue="HRM Installed?">
                    <Apex:outputfield value="{!obj.HRM_Installed__c}"/>
                    
                </apex:column>
                
            </apex:pageblockTable>
        </Apex:pageblock>
        
    </apex:form>
    
</apex:page>

 Thanks for the help!!

Hello!

 

I am looking to add a button to each row in my pageblocktable and the button should call the value of the URL field called loginURL__c. Basically I'm trying to take the column in my pageblock which is a field value and make it a button. I'm having trouble even getting started with this one. All the only resources only show how to add a button to the top of a pageblocktable, which I've done and its not what I'm looking for.

 

Can anybody help me get going in the right direction?

 

VFP:

 

<apex:page controller="listorgs">

    <apex:form >
    
        <Apex:pageblock >
          <Apex:pageblockButtons >
                        <Apex:commandButton value="login" onclick="openpage('login'); return false;"/>
                        </Apex:pageblockButtons>
        <br/>
        <br/>
            
            <apex:pageblockTable value="{!newlist}" var="obj">
                
                <apex:column >
                    <Apex:outputfield value="{!obj.name}"/>
                    
                </apex:column>
                
                <apex:column >
                    <Apex:outputfield value="{!obj.LoginURL__c}"/>
                    
                </apex:column>
                
                <apex:column >
                    <Apex:outputfield value="{!obj.Description__c}"/>
                    
                </apex:column>
                
                <apex:column >
                    <Apex:outputfield value="{!obj.HRM_Installed__c}"/>
                    
                </apex:column>
                
            </apex:pageblockTable>
        </Apex:pageblock>
        
    </apex:form>
    
</apex:page>

 

Controlling Class:

 

Public class listorgs
    implements iterator<org__c>{
        public static List<org__c> newlist {get; set;}
        Integer i {get; set;}
        
        public listorgs(){
            newlist = [select id, name , LoginURL__c , HRM_Installed__c, Description__c from org__c];
            i = 0;
                }
        Public boolean hasnext(){
            if(i>= newlist.size()){
                return false;
            } else {
                return true;
            }
        }
        Public Org__c next(){
            if(i==100){return null;}
            i++;
            return newlist[i-1];
        }
        public string page{get;set;}
        public string openpageurl {get;set;}
		
        public void onload()
        {
            page = '';
            openpageurl = '';
        }
        
        public pagereference redirect()
        {
           if( page == 'login')
            {
                openpageurl = 'http://google.com';
            }
            return null;
        }
}

    

 

Thanks for the tips!!!

I am getting this error "value for <apex:outputField> is not a dynamic binding!" on my VFP and not sure why. I read somewhere on forumns that this can be caused potentially by multi-currency being enabled, which I do have on but I'm not 100% sure that has anything to do with it.

 

VFP:

 

<apex:page controller="listorgs">

    <apex:form >
    
        <Apex:pageblock >

            <apex:pageblockTable value="{!newlist}" var="obj">
                <apex:column >
                    <Apex:outputfield value="obj.name"/>
                </apex:column>
            </apex:pageblockTable>
        </Apex:pageblock>
        
    </apex:form>
    
</apex:page>

 

Controlling class:

 

Public class listorgs
    implements iterator<org__c>{
        public static List<org__c> newlist {get; set;}
        Integer i {get; set;}
        
        public listorgs(){
            newlist = [select id, name from org__c];
            i = 0;
                }
        Public boolean hasnext(){
            if(i>= newlist.size()){
                return false;
            } else {
                return true;
            }
        }
        Public Org__c next(){
            if(i==100){return null;}
            i++;
            return newlist[i-1];
        }
}

    

 

Thanks to anyone who can help!

 

Hello, I am very new to writing both VF and Apex. I know this question is rudementary but I'm still struggling with getting the below solution to work. 

 

I am looking to create a visualforce page that will display all the records within a custom object I built, Org__c.

 

Below is the class I built to gather the data and pass into the pageblocktable. I'm assuming I have some extra code here that I could probably get rid of, as a side note. 

 

Global class listorgs
    implements iterator<org__c>{
        List<org__c> newlist {get; set;}
        Integer i {get; set;}
        
        public listorgs(){
            newlist = [select id, name from org__c];
            i = 0;
                }
        Global boolean hasnext(){
            if(i>= newlist.size()){
                return false;
            } else {
                return true;
            }
        }
        Global Org__c next(){
            if(i==100){return null;}
            i++;
            return newlist[i-1];
        }
}

    

 And here is the VFP. Note that I don't necessaryly have a variable called "name" but I just don't know what to put there. Any tips on that would be helpful as well as letting me know whats causing my VF to not be able to find the wrapper apex above.

 

<apex:page>

    <apex:form >
    
        <Apex:pageblock >
        <br/>
        <br/>
            <apex:commandButton value="Add Row" action="{!addrecord}" />
            
            <apex:pageblockTable value="{!listorgs}" var="name">
            
            </apex:pageblockTable>
        </Apex:pageblock>
        
    </apex:form>
    
</apex:page>

 

Thanks ahead of time for anyone who's willing to help!!

There is a Record Creater User A  with timezone is Timezone A and Record Viewer is another User B with TimezoneB.  

 

I have a custom object with Datetime field. When i fetch this record using SOQL for User B, SF gives the Datetime value in GMT with respect to the creator user's timezone and i wanted to get the absolute value that i have entered. I didnot find any way to identify in which timezone i have created that record. 

 

Can anybody tell me that how can i fetch that a record is created in which timezone?