• umair ayaz
  • NEWBIE
  • 10 Points
  • Member since 2017

  • Chatter
    Feed
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 8
    Questions
  • 0
    Replies
Hi there, I am currently working on a requirement for sprint burndown component.. the sprint object contains user stories which has seperate task and hours.
Which means the sprint has the days and hours and i want to create a burndown chart based on those values. Below is a sample sprint burndown chart and i have to achieve something like this.
User-added image
Any idea on how to achieve it? TIA
Hello Everyone I am new to Jquery and I have got a requirement to crate a list which could be sorted by drag and drop. Initially my plan was to get the order number using the positions but this method was not helpful becuase in differant related lists it has differant order number. So my only option is to get the Id of the updated record. I have tried many things but i am not able to get the Id as i should try some dynamic method. Would be great if anyone could guide me on how to get the Id. I have added my Visualforce and jquery code below.
 
<apex:page controller="DragController" >
    <head>
        <meta charset="utf-8"/>
        <meta name="viewport" content="width=device-width, initial-scale=1"/>
        <title>jQuery UI Sortable - Default functionality</title>
        <link rel="stylesheet" href="//code.jquery.com/ui/1.12.1/themes/base/jquery-ui.css"/>
        <link rel="stylesheet" href="/resources/demos/style.css"/>
        <style>
            #sortable { list-style-type: none; margin: 0; padding: 0; width: 60%; }
            #sortable li { margin: 0 3px 3px 3px; padding: 0.4em; padding-left: 1.5em; font-size: 1.4em; height: 35px; }
            #sortable li span { position: absolute; margin-left: -1.3em; }
        </style>
        <script src="https://code.jquery.com/jquery-1.12.4.js"></script>
        <script src="https://code.jquery.com/ui/1.12.1/jquery-ui.js"></script>
        <script>
        $( function() {
            $( "#sortable" ).sortable({
                start: function(event, ui) {

                    var start_pos = ui.item.index();
                    ui.item.data('start_pos', start_pos);
                    
                },
                change: function(event, ui) {
                    var start_pos = ui.item.data('start_pos');

                    if (start_pos < index) {
                        $('#sortable li:nth-child(' + index + ')').addClass('highlights');
                    } else {
                        $('#sortable li:eq(' + (index + 1) + ')').addClass('highlights');
                    }
                },
                update: function(event, ui) {
                    var start_pos = ui.item.data('start_pos');
                    var end_pos = ui.item.index();
                    var order_number = end_pos+1;
                    var fnumber = start_pos+1;
                    var test = $('#test').attr('name'); 

                    alert ("starting order "+fnumber);
                    alert ("Ending order "+order_number);
                    alert (test);
          
                    startingOrder(fnumber);
               
                    $('#sortable li').removeClass('highlights');
                }   
                
            });
            
            $( "#sortable" ).disableSelection();
            
        } );        
        
        </script>
    </head>
    <body>
        <apex:form id="form">
      
            <ul id="sortable">
                <apex:repeat value="{!Accounts}" var="acc">
                    
                    <li class="ui-state-default" id="{!acc.id}"   >
                        <span id="test" name="{!acc.id}">{!acc.id}</span></li>
                </apex:repeat>
                
                <apex:actionFunction action="{!updateOrder}" name="startingOrder" reRender="form" > 
                    <apex:param name="param1" value="{!starting_order}"/> 
                </apex:actionFunction>
                
            </ul> 
        </apex:form>        
    </body>    
</apex:page>

 
Hello salesforce experts. I need help in order to update a custom field with apex trigger. Basically i have a table that shows all the accounts and i am using a custom field named order to sort the table according to the order field. Below is the picture of the table
User-added image

Now i am trying to update the other record's order numbers automatically when an order number is changed. E.g:- If i change order number "2" to "5", the record which alrady had the order number "5" should change its order number to "4" and old order number "4" should be changed to "3" and old order number "3" should be changed to "2". I have written a trigger for it and i am very close to the completed solution but the only problem i am facing is that when i  change order number "2" to "5" then there are 2 records with order number "5" and both of them change to order number "4". Please if anyone got some time then please check my codes and tell me the ways i could improve it. and if you are still not clear about the problem do let me know. My Trigger is atached below
 
trigger trigger1 on Account ( before update) {
    public List <Account> account=new List <Account>();
    public Integer currentRecordId {get;set;}
    public Integer num {get;set;}
    public Integer num1 {get;set;}
    account = [SELECT Id, Name  FROM Account WHERE Id IN :Trigger.New]; 
    public List <Integer> oldOrder=new List <Integer>();
    public List <Integer> newOrder=new List <Integer>();
    
    System.debug('run 1');
    
    for (Account acc: Trigger.new) {
        Account accOld = Trigger.oldMap.get(acc.id);
        
        system.debug('Old order number'+accOld.order__c);
        system.debug('new order number'+acc.order__c);
        
        try{
            
            if(acc.order__c != accOld.order__c) {                             
                // System.debug('---------Old order---------->'+accOld.order__c);
                // System.debug('---------new greaqter than old---------->'+acc.order__c);
                num = integer.valueOf(accOld.order__c);
                num1 = integer.valueOf(acc.order__c);
                oldOrder.add(num);
                newOrder.add(num1);            
            }
            
            
            if(acc.order__c > oldOrder[0] && acc.order__c <= newOrder[0]  ){
                
                System.debug('---------numbers in between---------->'+acc.Name);
                acc.order__c=acc.order__c-1;
                if(accOld.order__c == acc.order__c){
                    System.debug('---------Record with same order number---------->'+acc.Name);
                
            }

                
            }
           
            else if(acc.order__c < oldOrder[0] && acc.order__c > newOrder[0]){
                System.debug('---------numbers in between---------->'+acc.Name);
                Account a = new Account(id = acc.Id);
                acc.order__c=acc.order__c+1;
                
               
            }
            
        }
        catch(Exception e) {}
    }
    
}

 
Hi,
I have a table with 3 output columns and 1 colum with input field just as shown in the picture below.
User-added image
I am trying to fire a trigger after the order number is updated. The problem that i am facing is that i want the id of the updated record only where as all the trigger functions display the IDs of all the records in the account and trigger.size returns the total number of records which means that all the records are being updated so my question is how do i get the id of the changed record in the trigger.

Here is my Visualforce page :- 
<apex:page controller="OrderAccountController" >
    <apex:form >
    <apex:pageBlock title="List of accounts">
                <apex:pageBlockButtons location="top"> 
        <apex:commandButton value="Reorder" action="{!save}" />
            </apex:pageBlockButtons> 
        <apex:pageBlockTable value="{!account}" var="a">
            <apex:column value="{!a.Name}"/>
            <apex:column value="{!a.Industry}"/>
            <apex:column value="{!a.Type}"/>
            <apex:column headerValue="Order Number">
            <apex:inputField value="{!a.order__c}" />
              
            </apex:column>
        
        
        </apex:pageBlockTable>
        </apex:pageBlock>

    </apex:form> 
    
</apex:page>

 Here is my custom controller
public class OrderAccountController {
    public List <Account> account=new List <Account>();
    public Account act{get;set;}
    
     public List <Account> getAccount() {
        account = [SELECT Id, Name, Site, Type, accountNumber, CustomerPriority__c, order__c, industry FROM Account order by order__c ];
        return account;
    }
    public PageReference save() {
        try {
            update account;
        }  

        catch(Exception e){
            System.debug('Exception occurred '+String.valueOf(e));
        }
        return NULL;
    }       
    

}

Here is my trigger
 
trigger trigger1 on Account (after update) {
    public List <Account> account=new List <Account>();
    Map<Id,Account> mp = new Map<Id,Account>(); 
    public Integer currentRecordId {get;set;}
     account = [SELECT Id, Name  FROM Account WHERE Id IN :Trigger.New];
     for(Account con :trigger.new){  
        
  }     
     system.debug(mp);
    
    
    for (Account acc: Trigger.new) {
		
		currentRecordId= trigger.size;

		}
    System.debug(currentRecordId);
	}

Any help regarding this would be much appreciated. Please help a beginner. Thanks in advance
Hi saleforce experts I am stucj with a small problem where i want to reorder my table according to order number so right now i have created a order number field and have ordered the table according to order number and the issue i am facing right now is for example if i change the order number 20 to order number 5 the record in order number 5 should change to order number 6 which means all the records between order number 5 to order number 20 should be added by 1. I have added my visualforce page codes and my controller codes below. please guide me on how it could be done. Thanks in advance

My visualforce code
<apex:page controller="OrderAccountController" >
    <apex:form>
    <apex:pageBlock title="List of accounts">
        <apex:pageBlockTable value="{!account}" var="a">
            <apex:column value="{!a.Name}"/>
            <apex:column value="{!a.Industry}"/>
            <apex:column value="{!a.Type}"/>
            <apex:column headerValue="Order Number">
            <apex:inputField value="{!a.order__c}"/>
            </apex:column>
        
        </apex:pageBlockTable>
        </apex:pageBlock>
        <apex:commandButton value="Reorder" action="{!save}" />
    </apex:form> 
    
</apex:page>

My apex code
public class OrderAccountController {
    public List <Account> account=new List <Account>();
    public Account act{get;set;}
    
     public List <Account> getAccount() {
        account = [SELECT Id, Name, Site, Type, accountNumber, CustomerPriority__c, order__c, industry FROM Account order by order__c ];
        return account;
    }
    public PageReference save() {
        try {
            update account;
        }  

        catch(Exception e){
            System.debug('Exception occurred '+String.valueOf(e));
        }
        return NULL;
    }       
    

}


 
Hello I am trying to validate account name. I want to check if the account with same name exists so i have written controller class method to check it but i am not able to call it from visuaforce page.
Following is my visualforce page
<apex:page controller="AddAccountController" tabStyle="Account" standardStylesheets="false" showHeader="false" sidebar="false">
    <style>
        .myFormStyle {
        background-color: #D3D3D3;
        }
        .tableBorder
        {
        
        border:3px outset black;
        }
        .innerTableBorder{
        border-top:2px dotted black;
        border-left:2px dotted black;
        }
    </style>
    <script>
     function AccountCheck() {
         
         var x = "{!checkAccount}"
       alert(x);
        }
    </script>
    
    
    
    <apex:form styleClass="myFormStyle">
        <div>
            <apex:pageBlock title="Add Account">
                <apex:pageBlockButtons location="top" >                   
                    <apex:commandButton value="Save" action="{!save}" reRender="accountList"  />
                    <apex:commandButton value="Cancel" action="{!cancel}" />
                    
                </apex:pageBlockButtons>  
                <apex:pageBlockSection title="Account Details" columns="1">            
                    <apex:inputField id="accountName" value="{!act.name}" onblur="AccountCheck()"/> 
                    <apex:inputField value="{!act.site}"/> 
                    <apex:inputField value="{!act.type}"/> 
                    <apex:inputField value="{!act.accountNumber}"/>              
                </apex:pageBlockSection>         
            <apex:pageBlockTable value="{!Account}" var="acc" id="accountList" styleClass="tableBorder">              
                <apex:column value="{!acc.Name}" styleClass="innerTableBorder" />            
                <apex:column value="{!acc.Site}" styleClass="innerTableBorder" />               
                <apex:column value="{!acc.type}" styleClass="innerTableBorder" />               
            </apex:pageBlockTable>
        </apex:pageBlock>
    </div>
</apex:form>
</apex:page>

Here on its my Controller
 
public class AddAccountController {
    
    public List <Account> account=new List <Account>();
    public Account act{get;set;}
    public integer counter {get;set;}
    
    public AddAccountController() {       
        act = new Account();
        this.counter=0;
    }
    
    public List <Account> getAccount() {
        account = [SELECT Id, Name, Site, Type FROM Account order by createddate desc limit 20];
        return account;
    }
    
    public PageReference cancel() {
        return null;
    }
    
    public PageReference save() {
        system.debug('act name:' + act.name + ' = ' + act.accountNumber);
        upsert act;
        return null;
    }
    public Integer checkAccount(){
        String accountName =System.currentPageReference().getParameters().get('accountName');
        account = [SELECT Id, Name, Site, Type FROM Account WHERE Name = :accountName];
        if(account.size()>0){
            counter=1;
            return counter;
        }
        return counter;
    }
}
Below is the error that i get please tell me why i get this error.
Unknown property 'AddAccountController.checkAccount'
I want it to call the checkAccount() method  from my javasccript function that i am calling from onblur method. So please experts help a newbie
 
I am new to salesforce and still under training so i need some help to check if account exists or not. Here is the code that i have written so far.

Following is my visualforce page
<apex:page controller="AddAccountController" tabStyle="Account" standardStylesheets="false" showHeader="false" sidebar="false">
    <style>
        .myFormStyle {
        background-color: #D3D3D3;
        }
        .tableBorder
        {
        
        border:3px outset black;
        }
        .innerTableBorder{
        border-top:2px dotted black;
        border-left:2px dotted black;
        }
        function myFunction() {
        var x = document.getElementById("fname");
        x.value = x.value.toUpperCase();
        }
    </style>
    
    
    
    <apex:form styleClass="myFormStyle">
        <div>
            <apex:pageBlock title="Add Account">
                <apex:pageBlockButtons location="top" >                   
                    <apex:commandButton value="Save" action="{!save}" reRender="accountList"  />
                    <apex:commandButton value="Cancel" action="{!cancel}" />
                </apex:pageBlockButtons>  
                <apex:pageBlockSection title="Account Details" columns="1">            
                    <apex:inputField id="accountName" value="{!act.name}"/> 
                    <apex:inputField value="{!act.site}"/> 
                    <apex:inputField value="{!act.type}"/> 
                    <apex:inputField value="{!act.accountNumber}"/>              
                </apex:pageBlockSection>         
            <apex:pageBlockTable value="{!Account}" var="acc" id="accountList" styleClass="tableBorder">              
                <apex:column value="{!acc.Name}" styleClass="innerTableBorder" />            
                <apex:column value="{!acc.Site}" styleClass="innerTableBorder" />               
                <apex:column value="{!acc.type}" styleClass="innerTableBorder" />               
            </apex:pageBlockTable>
        </apex:pageBlock>
    </div>
</apex:form>
</apex:page>

Here on its my controller
 
public class AddAccountController {
    
    public List <Account> account=new List <Account>();
    public Account act{get;set;}
    
    public AddAccountController() {       
        act = new Account();
    }
    
    public List <Account> getAccount() {
        account = [SELECT Id, Name, Site, Type FROM Account order by createddate desc limit 20];
        return account;
    }
    
    public PageReference cancel() {
        return null;
    }
    
    public PageReference save() {
        system.debug('act name:' + act.name + ' = ' + act.accountNumber);
        upsert act;
        return null;
    }
    public Account checkAccount(){
        String accountName =System.currentPageReference().getParameters().get('accountName');
        account = [SELECT Id, Name, Site, Type FROM Account WHERE Name = accountName];
        return act;
    }
}

I am trying to get an icon next to account name field if it exists. Right now my plan is to check if the account exists in the Account array list. if it does then i would like to show a cross next to account field and if it does not exist then a tick next to the account field. Help would be appreciated.
 
Hi I am a newbie to visualforce. I am trying to create a visualforce page that displays all the accounts in a table and a form that allows to save accounts. I have written coding but facing issues.

Following is my visualpage sourcecodes.
<apex:page controller="AddAccountController" tabStyle="Account" showHeader="false" sidebar="false">
     <apex:form >
   <apex:pageBlock title="Add Account">
       
       
       <apex:pageBlockSection title="Account Details" columns="1"> 

                <apex:inputField value="{!Account.name}" /> 
                <apex:inputField value="{!Account.site}"/> 
                <apex:inputField value="{!Account.type}"/> 
                <apex:inputField value="{!Account.accountNumber}"/> 
           		<apex:commandButton value="Save" action="{!save}">
                <apex:commandButton value="Cancel" action="#">
                    </apex:commandButton>
           </apex:commandButton>
            </apex:pageBlockSection> 
       
<apex:pageBlockTable value="{!Account}" var="account"> 

      <apex:column value="{!account.Name}"/> 

      <apex:column value="{!account.Site}"/> 

      <apex:column value="{!account.type}"/> 

   </apex:pageBlockTable> 


    </apex:pageBlock>
      </apex:form>
</apex:page>
Here on its my AddAccountController class
public class AddAccountController {

    public List <Account> account=new List <Account>();
    public Account act{get;set;}

    public AddAccountController() {
        account = [SELECT Id, Name, Site FROM Account];                 
    }

    public List <Account> getAccount() {
        return account;
    }

    public PageReference save() {
        upsert (account);
        return null;
    }
}
 
Could not resolve the entity from <apex:inputField> value binding '{!account.name}'. <apex:inputField> can only be used with SObjects, or objects that are Visualforce field component resolvable.
This is the error that i get. Please experts help a newbie :).