• rajesh k 10
  • NEWBIE
  • 125 Points
  • Member since 2014

  • Chatter
    Feed
  • 1
    Best Answers
  • 4
    Likes Received
  • 1
    Likes Given
  • 89
    Questions
  • 171
    Replies
public with sharing class AccountPagination {
    private final Account acct;  

    // The constructor passes in the standard controller defined
    // in the markup below
            public AccountPagination(ApexPages.StandardSetController controller) {
        this.acct = (Account)controller.getRecord(); 
    }    
    
    public ApexPages.StandardSetController accountRecords {
        get {
            if(accountRecords == null) {
                accountRecords = new ApexPages.StandardSetController(
                    Database.getQueryLocator([SELECT Name FROM Account WHERE Id NOT IN 
                        (SELECT AccountId FROM Opportunity WHERE IsClosed = true)]));
            }
            return accountRecords;
        }
        private set;
    }
    public List<Account> getAccountPagination() {
         return (List<Account>) accountRecords.getRecords();
    }  
}
Hi,
Below code showing Records in Table .How can show these records as picklist
 
public void fetch()
    {
        errMsg  = 'Some error occurred, please try again';
        try
        {
        //-----------------------------------
        // Login via SOAP/XML web service api
        //-----------------------------------
        HttpRequest request = new HttpRequest();
        request.setEndpoint('https://' + LOGIN_DOMAIN + '.salesforce.com/services/Soap/u/29.0');
        System.debug(request);
        request.setMethod('POST');
        System.debug(request);
        request.setHeader('Content-Type', 'text/xml;charset=UTF-8');
        System.debug(request);
        request.setHeader('SOAPAction', '""');
        System.debug(request);
        //not escaping username and password because we're setting those variables above
        //in other words, this line "trusts" the lines above
        //if username and password were sourced elsewhere, they'd need to be escaped below
        request.setBody('<Envelope xmlns="http://schemas.xmlsoap.org/soap/envelope/"><Header/><Body><login xmlns="urn:partner.soap.sforce.com"><username>' + userName+ '</username><password>' + pwd+ '</password></login></Body></Envelope>');
        Dom.XmlNode resultElmt = (new Http()).send(request).getBodyDocument().getRootElement()
          .getChildElement('Body', 'http://schemas.xmlsoap.org/soap/envelope/')
          .getChildElement('loginResponse', 'urn:partner.soap.sforce.com')
          .getChildElement('result', 'urn:partner.soap.sforce.com');
          System.debug(request);

        //-------------------------------
        // Grab session id and server url
        //--------------------------------
        final String SERVER_URL = resultElmt.getChildElement('serverUrl', 'urn:partner.soap.sforce.com') .getText().split('/services')[0];
        final String SESSION_ID = resultElmt.getChildElement('sessionId', 'urn:partner.soap.sforce.com') .getText();

        //----------------------------------
        // Load first 10 accounts via REST API
        //---------------------------------
        final PageReference theUrl = new PageReference(SERVER_URL + '/services/data/v22.0/query/');
        theUrl.getParameters().put('q','Select a.Phone, a.Name, a.CreatedBy.FirstName, a.CreatedById From Account a limit 10');
        request = new HttpRequest();
        request.setEndpoint(theUrl.getUrl());
        request.setMethod('GET');
        request.setHeader('Authorization', 'OAuth ' + SESSION_ID);

        String body = (new Http()).send(request).getBody();

        JSONParser parser = JSON.createParser(body);

        do{
            parser.nextToken();
        }while(parser.hasCurrentToken() && !'records'.equals(parser.getCurrentName()));

        parser.nextToken();

        acc = (List<Account>) parser.readValueAs(List<Account>.class);
        }
        catch(Exception e)
        {
            displayError = 'block';
        }

    }
For showing picklist i tried like below but its not working.Could you please help
errMsg  = 'Some error occurred, please try again';
        try
        {
        //-----------------------------------
        // Login via SOAP/XML web service api
        //-----------------------------------
        HttpRequest request = new HttpRequest();
        request.setEndpoint('https://' + LOGIN_DOMAIN + '.salesforce.com/services/Soap/u/29.0');
        System.debug(request);
        request.setMethod('POST');
        System.debug(request);
        request.setHeader('Content-Type', 'text/xml;charset=UTF-8');
        System.debug(request);
        request.setHeader('SOAPAction', '""');
        System.debug(request);
        //not escaping username and password because we're setting those variables above
        //in other words, this line "trusts" the lines above
        //if username and password were sourced elsewhere, they'd need to be escaped below
        request.setBody('<Envelope xmlns="http://schemas.xmlsoap.org/soap/envelope/"><Header/><Body><login xmlns="urn:partner.soap.sforce.com"><username>' + userName+ '</username><password>' + pwd+ '</password></login></Body></Envelope>');
        Dom.XmlNode resultElmt = (new Http()).send(request).getBodyDocument().getRootElement()
          .getChildElement('Body', 'http://schemas.xmlsoap.org/soap/envelope/')
          .getChildElement('loginResponse', 'urn:partner.soap.sforce.com')
          .getChildElement('result', 'urn:partner.soap.sforce.com');
          System.debug(request);

        //-------------------------------
        // Grab session id and server url
        //--------------------------------
        final String SERVER_URL = resultElmt.getChildElement('serverUrl', 'urn:partner.soap.sforce.com') .getText().split('/services')[0];
        final String SESSION_ID = resultElmt.getChildElement('sessionId', 'urn:partner.soap.sforce.com') .getText();

        //----------------------------------
        // Load first 10 accounts via REST API
        //---------------------------------
        final PageReference theUrl = new PageReference(SERVER_URL + '/services/data/v22.0/query/');
        Account [] accounts=[SElECT Name, Id FROM Account];
        System.debug('******accounts****'+accounts);
        //theUrl.getParameters().put('q','Select a.Phone, a.Name, a.CreatedBy.FirstName, a.CreatedById From Account a limit 10');
        List<SelectOption> options = new List<SelectOption>();
        for (Account a : accounts) {
        System.debug('******accounts****'+a);
        options.add(new SelectOption(a.Id,a.Name)); 
        System.debug('******options****'+options);       
    }
   // accountList =options;
        request = new HttpRequest();
        request.setEndpoint(theUrl.getUrl());
        request.setMethod('GET');
        request.setHeader('Authorization', 'OAuth ' + SESSION_ID);
        System.debug('******request****'+request); 

        String body = (new Http()).send(request).getBody();
        System.debug('******body ****'+body);

        JSONParser parser = JSON.createParser(body);

        do{
            parser.nextToken();
        }while(parser.hasCurrentToken() && !'records'.equals(parser.getCurrentName()));

        parser.nextToken();

        options= (List<SelectOption>) parser.readValueAs(List<SelectOption>.class);
        accountList =options;
        }
        catch(Exception e)
        {
            displayError = 'block';
        }
Thanks,


 
Hi,
I have single Excel sheet but this single excel sheet having multiple sheets(means multiple objects each sheet).How to import multiple sheets(means multiple objects with single excel with different sheets).

Using below code i was done import for single excel sheet for single object with but how to do import multiple objects(means i have one excel but this excel having multiple sheets(means multiple objects))
 
<apex:page controller="importDataFromCSVController">
    <apex:form >
        <apex:pagemessages />
        <apex:pageBlock >
            <apex:pageBlockSection columns="4">
                  <apex:inputFile value="{!csvFileBody}"  filename="{!csvAsString}"/>
                  <apex:commandButton value="Import Account" action="{!importCSVFile}"/>
            </apex:pageBlockSection>
        </apex:pageBlock>
        <apex:pageBlock >
           <apex:pageblocktable value="{!accList}" var="acc">
              <apex:column value="{!acc.name}" />
              <apex:column value="{!acc.AccountNumber}" />
              <apex:column value="{!acc.Type}" />
              <apex:column value="{!acc.Accountsource}" />
              <apex:column value="{!acc.Industry }" />
        </apex:pageblocktable>
     </apex:pageBlock>
   </apex:form>
</apex:page>
public class importDataFromCSVController {
public Blob csvFileBody{get;set;}
public string csvAsString{get;set;}
public String[] csvFileLines{get;set;}
public List<account> acclist{get;set;}
  public importDataFromCSVController(){
    csvFileLines = new String[]{};
    acclist = New List<Account>();
  }
  
  public void importCSVFile(){
       try{
           csvAsString = csvFileBody.toString();
           csvFileLines = csvAsString.split('\n');
            
           for(Integer i=1;i<csvFileLines.size();i++){
               Account accObj = new Account() ;
               string[] csvRecordData = csvFileLines[i].split(',');
               accObj.name = csvRecordData[0] ;            
               accObj.accountnumber = csvRecordData[1];
               accObj.Type = csvRecordData[2];
               accObj.AccountSource = csvRecordData[3];  
               accObj.Industry = csvRecordData[4];                                                                            
               acclist.add(accObj);  
           }
        //insert acclist;
        }
        catch (Exception e)
        {
            ApexPages.Message errorMessage = new ApexPages.Message(ApexPages.severity.ERROR,'An error has occured while importin data Please make sure input csv file is correct');
            ApexPages.addMessage(errorMessage);
        } 
  }
}




thanks
Hi,
       Using vf page I calculated 
<apex:column headerValue="Total">
                         <apex:outputtext value="$ {!IF(Inpitem.includedProduct.Quantity__c > 0 , Inpitem.includedProduct.Quantity__c * ProductidToPricebookEntry[Inpitem.includedProduct.Product__c], 0)}">
                           <apex:variable var="grandTotal" value="{!grandTotal + (Inpitem.includedProduct.Quantity__c * ProductidToPricebookEntry[Inpitem.includedProduct.Product__c])}" />
                        </apex:outputtext>
                        </apex:column>

In controller i constructed map like below
 
for (PricebookEntry pricBkEntry: [SELECT Product2Id, Pricebook2Id, UnitPrice FROM PriceBookEntry WHERE Product2Id IN: productids AND Pricebook2Id = : pricebookid AND CurrencyIsoCode = 'USD']) {
                Decimal Listprice = pricBkEntry.UnitPrice;
                ProductidToPricebookEntry.put(pricBkEntry.Product2Id, Listprice);
            }

I was getting some times Map Key not Exist(It show in like 01tD000000108Mw(ProductId) with visualforce page culcuation).How can i chaeck Map Condition here 

help me...
Hi,
        Using get method I displayed.Without using get method same how to display Picklist values
 
<apex:selectList value="{!selectedPicebookIds}" size="1">
                <apex:selectOptions value="{!PricebookNames}" />
                <apex:actionSupport event="onchange" reRender="bundle,allsections,errormesg" status="status" />
                <apex:actionstatus id="status">
                    <apex:facet name="start">
                        <div class="waitingSearchDiv" id="el_loading" style="background-color: #fbfbfb;
                               height: 100%;opacity:0.65;width:100%;">
                            <div class="waitingHolder" style="top: 74.2px; width: 91px;">
                                <img class="waitingImage" src="/img/loading.gif" title="Please Wait..." />
                                <span class="waitingDescription">Please Wait...</span>
                            </div>
                        </div>
                    </apex:facet>
                </apex:actionstatus>
            </apex:selectList>
            <br/>
            <br/> Bundle&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
            <apex:selectList value="{!selectedBundleId}" size="1" id="bundle">
                <apex:selectOptions value="{!BundleNames}" />
                <apex:actionSupport id="adOnProductType" event="onchange" status="status1" rerender="allsections,errormesg" /><!-- rerender="adOnInfo,errormesg,IncludedProInfo,product" /> -->
                <apex:actionstatus id="status1">
                    <apex:facet name="start">
                        <div class="waitingSearchDiv" id="el_loading" style="background-color: #fbfbfb;
                       height: 100%;opacity:0.65;width:100%;">
                            <div class="waitingHolder" style="top: 74.2px; width: 91px;">
                                <img class="waitingImage" src="/img/loading.gif" title="Please Wait..." />
                                <span class="waitingDescription">Please Wait...</span>
                            </div>
                        </div>
                    </apex:facet>
                </apex:actionstatus>
            </apex:selectList>

Controller:
==========
public List < SelectOption > getPricebookNames() {
            pricebookid = opp.Pricebook2Id;
            List < SelectOption > Options = new List < SelectOption > ();
            pricebookList = [select Id, name FROM Pricebook2 WHERE Id = : pricebookid];
            if (pricebookid != NULL) {
                for (Pricebook2 price: pricebookList) {
                    if (price.id == Opp.Pricebook2Id) {
                        Options.add(new SelectOption(Opp.Pricebook2Id, price.name));
                        getBundleNames();
                    }
                }
            } else {
                Options.add(new SelectOption('', '--Select--'));
                pricebookList1 = [select Id, name FROM Pricebook2];
                System.debug(pricebookList1);
                for (Pricebook2 price1: pricebookList1) {
                    Options.add(new SelectOption(price1.Id, price1.name));
                    getBundleNames();

                }
            }

            return Options;
        }
    public List < SelectOption > getBundleNames() {
        List < SelectOption > bundleOptions = new List < SelectOption > ();
        System.debug(pricebookid);
       if (pricebookid != NULL) {
            bundleList = [select Id, name, Price_Book__c FROM Bundle__c WHERE Price_Book__c = : pricebookid];
            System.debug(bundleList);
            bundleId = bundleList[0].Id;
            if (bundleList.size() > 0) {
                for (Bundle__c bundle: bundleList) {
                    bundleOptions.add(new SelectOption(bundle.Id, bundle.name));
                }
                BundlePopulatedRecordsMethod();
            } else {
                bundleOptions.add(new SelectOption('', '--Select--'));
            }
        }
help me...
 
Hi,
         
set<Id> proids=new Set<Id>();
            productList = [select id, name,Quantity__c from Product2 where Every_Bundle__c=TRUE];
            System.debug('&&&&conlist  &&&&&' + OptionalAdOnProductList);
            if (productList.size() > 0) {
                for (Product2 iterateproduct: productList) {
                    allProductsEveryBundleCheckboxcheckedList.add(new WrapperOfProducts(iterateproduct));
                    proids.add(iterateproduct.id);
                }
             List<PricebookEntry> listOfProductRelatedPricebookEntry=new List<PricebookEntry>();
             listOfProductRelatedPricebookEntry=[SELECT Product2Id,Pricebook2Id,UnitPrice FROM PriceBookEntry WHERE Product2Id IN :proids AND CurrencyIsoCode='USD'];
             
             for(PricebookEntry pricBkEntry :listOfProductRelatedPricebookEntry){
             Decimal Listprice=pricBkEntry.UnitPrice;
              mapToProducts.put(pricBkEntry.Product2Id,Listprice);
      			}
            }

Help me...
hi,
        
<apex:dataTable value="{!listOfOptionalAdOnWrapper}" var="pitem" rowClasses="odd,even" width="100%" rendered="{!listOfOptionalAdOnWrapper.size > 0}">
                        <apex:column headerValue="Action">

                            <apex:inputCheckbox value="{!pitem.isSelected}" id="InputId" />
                        </apex:column>
                        <apex:column headerValue="Name">

                            <apex:outputField value="{!pitem.optionaladon.Name}" />
                        </apex:column>
                       <apex:column headerValue="Quantity">

                            <apex:outputField value="{!pitem.optionaladon.Quantity__c}">
                                   <apex:inlineEditSupport event="ondblclick" showOnEdit="update" />
                            </apex:outputField>
                        </apex:column> 
                        <apex:column headerValue="list Price">

                         <apex:outputtext value="{!ProductidToPricebookEntryOfOptionalAdOnProduct[pitem.optionaladon.Product__c]}"/> 

                        </apex:column>
                         <apex:column headerValue="Total">

                          <apex:facet name="footer">
                                <strong> Total: </strong>
                            </apex:facet>
                        </apex:column>
                    </apex:dataTable>

Controller:
public List < Optional_Ons__c > OptionalAdOnProductList {get;set;}
public  Map<Id,Decimal>  ProductidToPricebookEntryOfOptionalAdOnProduct{get;set;}


 Set<Id> productisOfOptionalAdon=new set<Id>();
            OptionalAdOnProductList = [select id, name,BObject__c,Quantity__c,Product__c from Optional_Ons__c  where BObject__c = : bId];
            if (OptionalOnProductList.size() > 0) {
                for (Optional_Ons__c iterateadOn: OptionalAdOnProductList) {
                    listOfOptionalAdOnWrapper.add(new OptionalAdOnWrapper(iterateadOn));
                    productisOfOptionalAdon.add(iterateadOn.Product__c);
                    System.debug('&&&&listOfWrapper&&&&&' + listOfOptionalAdOnWrapper);
                }
            }
            //Ger all the products related Pricebook as well as bundle object selected Pricebook match
            for(PricebookEntry pricBkEntry : [SELECT Product2Id,Pricebook2Id,UnitPrice FROM PriceBookEntry WHERE Product2Id IN :productisOfOptionalAdon AND Pricebook2Id = :pricebookid AND CurrencyIsoCode='USD']){
			       Decimal Listprice=pricBkEntry.UnitPrice;
			        ProductidToPricebookEntryOfOptionalAdOnProduct.put(pricBkEntry.Product2Id,Listprice);
			}

//Wrapper class

public class OptionalAdOnWrapper {
        public Boolean isselected {get;set;}
        public Optional_Ons__c optionaladon {get;set;}
        public OptionalAdOnWrapper(Optional_Ons__c optional) {
            this.optionaladon = optional;
            this.isselected   =False;
        }
    }

Action            Productname Quantity   Listprice   Total
checkbox        xxxx               123         500          ?
checkbox        yyyy                321        400           ?
                                                        
                                                           Grand Total:?

Please help me How to calculate Total and Grand Total?
Hi,
          map<Id,list<PricebookEntry>>  ProductidToPricebookEntry = new map<Id,list<PricebookEntry>>();
            set<ID> productids=new set<ID>();
            for(In_Product__c ip:InProductList)
            {
                productids.add(ip.Product__c);
               if(ProductidToPricebookEntry.containsKey(ip.Product__c))
                {
                    ProductidToPricebookEntry.get(ip.Product__c);
                }
            }
           
Hi, 
<table>
                    <tr>
                        <td>Action</td>
                        <td>Name</td>
                        <td>Phone</td>
                    </tr>

                    <apex:repeat value="{!listOfAccountRelatedWrapper}" var="m">

                        <tr>
                            <td>
                                <apex:inputCheckbox value="{!m.isSelected}" id="InputId" />
                            </td>
                            <td>
                                <apex:outputField value="{!m.con.Name}" id="adonProductName" />
                            </td>
                            <td>
                                <apex:outputField value="{!m.con.Phone}" id="adonProductQuality">
                                    <apex:inlineEditSupport event="ondblClick" showOnEdit="saveButton,cancelButton" hideOnEdit="editButton" />
                                </apex:outputField>
                            </td>
                        </tr>
                    </apex:repeat>

                    </table>

User-added image
I want to show
Action          Name       Phone
checkbox     www        12345(this is Editable field)

help me...
Hi,
       I displayed all account names under picklist.Based on selected picklist value how to display Contact records fields using <apex:repeat/>

thanks,
Rajesh
Hi,
      trigger AccountDuplicateTrg on Account (before insert,before update)
{
Map<string,Account> accMap = new Map<string,Account>();
set<string> accSet = new set<string>();
    for(Account acc : Trigger.new)
        accSet.add(acc.name);
    for(Account a : [select id,name from Account where name in : accSet])
        accMap.put(a.name,a);
    for(Account acc1 : trigger.new)
        {
        if(accMap.containskey(acc1.name))
           if(Trigger.isInsert){
             acc1.addError('There is another account in the system with this exact name and is a likely duplicate');
           }
           else if(Trigger.isUpdate){
               acc1.addError('There is another Account with the same name as this one. Please navigate to the Account tab');
           
           }
        }
  }

How to apply below senario above trigger updation time

I created a check box named "displayerror". Now in trigger if this check box is true, then throw the error. If check box is false then save the record and have the default value for this check box as true.So when user gets this error he can know the existence of a duplicate account and then in order to save the account he can uncheck the check box which inturn will save the record.

please help me...

 
Hi,
When a new account is being created, test the account name against all other account names already in the system. If there is an exact match, then prevent the save and pop this alert:
> “Duplicate account record exist”

- When saving an existing account, on save, also run the test to look for an exact name match on the account name (ensure you don’t find the same account as the one being saved). In this situation, if there is an exact match, we will still allow the save, but we’ll pop this alert as a warning:
> “There is another Account with the same name as this one. Please navigate to the Account tab, and in the Tools section on that page, execute the Account Merge in order to clean up this duplicate. If you are not the account owner of both accounts, please contact the account owner(s) and ask them to do this merge.”

help me...........
Hi,
        Using apex I converted Person account to businessAccount and Contact
- after creating the new business account and contact record, How to evaluate the following child records: ?
> activities: reassign the name and related to fields (whichever may be populated, one, the other, or both) from the originating person account to the new business account 
> opportunities: reassign the Account Name of the opportunity from the PA to the new BA 
> opportunity contact roles: for any contacts noted in the opportunity that point to the originating contact (which would be the originating person account record), reassign this to the new contact record. Ensure that the Primary checkbox and the role selection are retained through the conversion. 

Please help me.......
Hi,
          Using FieldDescribeResult How to add account custom fields to Contact custom Fields without hardcoding?

 
How to integrate salesforce with oracle database ?
Hi,
I have single Excel sheet but this single excel sheet having multiple sheets(means multiple objects each sheet).How to import multiple sheets(means multiple objects with single excel with different sheets).

Using below code i was done import for single excel sheet for single object with but how to do import multiple objects(means i have one excel but this excel having multiple sheets(means multiple objects))
 
<apex:page controller="importDataFromCSVController">
    <apex:form >
        <apex:pagemessages />
        <apex:pageBlock >
            <apex:pageBlockSection columns="4">
                  <apex:inputFile value="{!csvFileBody}"  filename="{!csvAsString}"/>
                  <apex:commandButton value="Import Account" action="{!importCSVFile}"/>
            </apex:pageBlockSection>
        </apex:pageBlock>
        <apex:pageBlock >
           <apex:pageblocktable value="{!accList}" var="acc">
              <apex:column value="{!acc.name}" />
              <apex:column value="{!acc.AccountNumber}" />
              <apex:column value="{!acc.Type}" />
              <apex:column value="{!acc.Accountsource}" />
              <apex:column value="{!acc.Industry }" />
        </apex:pageblocktable>
     </apex:pageBlock>
   </apex:form>
</apex:page>
public class importDataFromCSVController {
public Blob csvFileBody{get;set;}
public string csvAsString{get;set;}
public String[] csvFileLines{get;set;}
public List<account> acclist{get;set;}
  public importDataFromCSVController(){
    csvFileLines = new String[]{};
    acclist = New List<Account>();
  }
  
  public void importCSVFile(){
       try{
           csvAsString = csvFileBody.toString();
           csvFileLines = csvAsString.split('\n');
            
           for(Integer i=1;i<csvFileLines.size();i++){
               Account accObj = new Account() ;
               string[] csvRecordData = csvFileLines[i].split(',');
               accObj.name = csvRecordData[0] ;            
               accObj.accountnumber = csvRecordData[1];
               accObj.Type = csvRecordData[2];
               accObj.AccountSource = csvRecordData[3];  
               accObj.Industry = csvRecordData[4];                                                                            
               acclist.add(accObj);  
           }
        //insert acclist;
        }
        catch (Exception e)
        {
            ApexPages.Message errorMessage = new ApexPages.Message(ApexPages.severity.ERROR,'An error has occured while importin data Please make sure input csv file is correct');
            ApexPages.addMessage(errorMessage);
        } 
  }
}




thanks
Hi,
         I have 2 datepicker fields in my visualforce page.I will give these two date fields and when i click search how to store these dates in session variables and how to call these entered dates in another visualforce page(i implemented these pages for sites that's why there is no link between these pages How to call first entered date values to another visualforce page using sessions)?

help me.......
Hi,
     Actually i displayed all fields dynamically in an visualforce page.I want In my fields Multipicklist fields are there .How to display Multipicklist fields as Checkboxes Dynamically?

help me.........
Hi ,
       Actually i created fields using metadata api but created fileds Field-Level Security for Profile(Administrator) place visible and editable checkboxes not checked(any profile not checked i am a administrator).Every time i will goto Setup->Manage->users>administrator->custom field level security->related object name and click view and checked to metadata created fields visible and editable.How to check this visible and editable checkboxes Using apex DML permissionsets dynamically through Coding?.

please help me.........
Hi All,

I need css for the following code, which should result like a google form..

<apex:page >
    <apex:form >
        <apex:pageBlock >
          <apex:pageblocksection title="How Do You Like it ?" columns="4" >
          <b>Best</b><apex:inputCheckbox />
          <b>Good</b><apex:inputCheckbox />
          <b>Poor</b><apex:inputCheckbox />
          <b>worst</b><apex:inputCheckbox />    
        </apex:pageblocksection>
        <apex:pageblocksection columns="4">
         <b>Comments</b> <apex:inputTextArea />
        </apex:pageblocksection>
        <apex:pageBlockButtons >
             <apex:commandButton value="Submit" action="{!Submit}"/>
        </apex:pageBlockButtons>
       </apex:pageBlock>
    </apex:form>
</apex:page>

Can anyone help me out??

Thanks,
Mounika
 
Hi,

Can anyone please suggest me how to create custom objects and custom fields dynamically through Java or apex code.
If it is through Java, please suggest me the supported Jars as well. Appreciate if you can share the code for the same.

Thanks,
Vasavi
Hi,
I have single Excel sheet but this single excel sheet having multiple sheets(means multiple objects each sheet).How to import multiple sheets(means multiple objects with single excel with different sheets).

Using below code i was done import for single excel sheet for single object with but how to do import multiple objects(means i have one excel but this excel having multiple sheets(means multiple objects))
 
<apex:page controller="importDataFromCSVController">
    <apex:form >
        <apex:pagemessages />
        <apex:pageBlock >
            <apex:pageBlockSection columns="4">
                  <apex:inputFile value="{!csvFileBody}"  filename="{!csvAsString}"/>
                  <apex:commandButton value="Import Account" action="{!importCSVFile}"/>
            </apex:pageBlockSection>
        </apex:pageBlock>
        <apex:pageBlock >
           <apex:pageblocktable value="{!accList}" var="acc">
              <apex:column value="{!acc.name}" />
              <apex:column value="{!acc.AccountNumber}" />
              <apex:column value="{!acc.Type}" />
              <apex:column value="{!acc.Accountsource}" />
              <apex:column value="{!acc.Industry }" />
        </apex:pageblocktable>
     </apex:pageBlock>
   </apex:form>
</apex:page>
public class importDataFromCSVController {
public Blob csvFileBody{get;set;}
public string csvAsString{get;set;}
public String[] csvFileLines{get;set;}
public List<account> acclist{get;set;}
  public importDataFromCSVController(){
    csvFileLines = new String[]{};
    acclist = New List<Account>();
  }
  
  public void importCSVFile(){
       try{
           csvAsString = csvFileBody.toString();
           csvFileLines = csvAsString.split('\n');
            
           for(Integer i=1;i<csvFileLines.size();i++){
               Account accObj = new Account() ;
               string[] csvRecordData = csvFileLines[i].split(',');
               accObj.name = csvRecordData[0] ;            
               accObj.accountnumber = csvRecordData[1];
               accObj.Type = csvRecordData[2];
               accObj.AccountSource = csvRecordData[3];  
               accObj.Industry = csvRecordData[4];                                                                            
               acclist.add(accObj);  
           }
        //insert acclist;
        }
        catch (Exception e)
        {
            ApexPages.Message errorMessage = new ApexPages.Message(ApexPages.severity.ERROR,'An error has occured while importin data Please make sure input csv file is correct');
            ApexPages.addMessage(errorMessage);
        } 
  }
}




thanks
hi,
        
<apex:dataTable value="{!listOfOptionalAdOnWrapper}" var="pitem" rowClasses="odd,even" width="100%" rendered="{!listOfOptionalAdOnWrapper.size > 0}">
                        <apex:column headerValue="Action">

                            <apex:inputCheckbox value="{!pitem.isSelected}" id="InputId" />
                        </apex:column>
                        <apex:column headerValue="Name">

                            <apex:outputField value="{!pitem.optionaladon.Name}" />
                        </apex:column>
                       <apex:column headerValue="Quantity">

                            <apex:outputField value="{!pitem.optionaladon.Quantity__c}">
                                   <apex:inlineEditSupport event="ondblclick" showOnEdit="update" />
                            </apex:outputField>
                        </apex:column> 
                        <apex:column headerValue="list Price">

                         <apex:outputtext value="{!ProductidToPricebookEntryOfOptionalAdOnProduct[pitem.optionaladon.Product__c]}"/> 

                        </apex:column>
                         <apex:column headerValue="Total">

                          <apex:facet name="footer">
                                <strong> Total: </strong>
                            </apex:facet>
                        </apex:column>
                    </apex:dataTable>

Controller:
public List < Optional_Ons__c > OptionalAdOnProductList {get;set;}
public  Map<Id,Decimal>  ProductidToPricebookEntryOfOptionalAdOnProduct{get;set;}


 Set<Id> productisOfOptionalAdon=new set<Id>();
            OptionalAdOnProductList = [select id, name,BObject__c,Quantity__c,Product__c from Optional_Ons__c  where BObject__c = : bId];
            if (OptionalOnProductList.size() > 0) {
                for (Optional_Ons__c iterateadOn: OptionalAdOnProductList) {
                    listOfOptionalAdOnWrapper.add(new OptionalAdOnWrapper(iterateadOn));
                    productisOfOptionalAdon.add(iterateadOn.Product__c);
                    System.debug('&&&&listOfWrapper&&&&&' + listOfOptionalAdOnWrapper);
                }
            }
            //Ger all the products related Pricebook as well as bundle object selected Pricebook match
            for(PricebookEntry pricBkEntry : [SELECT Product2Id,Pricebook2Id,UnitPrice FROM PriceBookEntry WHERE Product2Id IN :productisOfOptionalAdon AND Pricebook2Id = :pricebookid AND CurrencyIsoCode='USD']){
			       Decimal Listprice=pricBkEntry.UnitPrice;
			        ProductidToPricebookEntryOfOptionalAdOnProduct.put(pricBkEntry.Product2Id,Listprice);
			}

//Wrapper class

public class OptionalAdOnWrapper {
        public Boolean isselected {get;set;}
        public Optional_Ons__c optionaladon {get;set;}
        public OptionalAdOnWrapper(Optional_Ons__c optional) {
            this.optionaladon = optional;
            this.isselected   =False;
        }
    }

Action            Productname Quantity   Listprice   Total
checkbox        xxxx               123         500          ?
checkbox        yyyy                321        400           ?
                                                        
                                                           Grand Total:?

Please help me How to calculate Total and Grand Total?
Hi, 
<table>
                    <tr>
                        <td>Action</td>
                        <td>Name</td>
                        <td>Phone</td>
                    </tr>

                    <apex:repeat value="{!listOfAccountRelatedWrapper}" var="m">

                        <tr>
                            <td>
                                <apex:inputCheckbox value="{!m.isSelected}" id="InputId" />
                            </td>
                            <td>
                                <apex:outputField value="{!m.con.Name}" id="adonProductName" />
                            </td>
                            <td>
                                <apex:outputField value="{!m.con.Phone}" id="adonProductQuality">
                                    <apex:inlineEditSupport event="ondblClick" showOnEdit="saveButton,cancelButton" hideOnEdit="editButton" />
                                </apex:outputField>
                            </td>
                        </tr>
                    </apex:repeat>

                    </table>

User-added image
I want to show
Action          Name       Phone
checkbox     www        12345(this is Editable field)

help me...
How can i put another checkbox on second Pageblock table Here is my code:
<apex:page controller="AccountSelectClassController" sidebar="false">
<!-- CheckBox -->
    <script type="text/javascript">
        function selectAllCheckboxes(obj,receivedInputID){
            var inputCheckBox = document.getElementsByTagName("input");
            for(var i=0; i<inputCheckBox.length; i++){
                if(inputCheckBox[i].id.indexOf(receivedInputID)!=-1){
                    inputCheckBox[i].checked = obj.checked;
                }
            }
        }
        
    </script>
    <apex:form >
        <apex:pageBlock >
            <apex:pageBlockButtons >
                <apex:commandButton value="Show Selected Accounts" action="{!processSelected}" rerender="table2"/>
            </apex:pageBlockButtons>
 
            <apex:pageblockSection title="All Accounts" collapsible="false" columns="2">
 
                <apex:pageBlockTable value="{!wrapAccountList}" var="accWrap" id="table" title="All Accounts">
                    <apex:column >
                        <apex:facet name="header">
                            <apex:inputCheckbox onclick="selectAllCheckboxes(this,'inputId')"/>
                        </apex:facet>
                        <apex:inputCheckbox value="{!accWrap.selected}" id="inputId"/>
                    </apex:column>
                    <apex:column value="{!accWrap.acc.Name}" />
                    <apex:column value="{!accWrap.acc.BillingState}" />
                    <apex:column value="{!accWrap.acc.Phone}" />
                </apex:pageBlockTable>
 
                <apex:pageBlockTable value="{!selectedAccounts}" var="c" id="table2" title="Selected Accounts">
                    <apex:column value="{!c.Name}" headerValue="Account Name"/>
                    <apex:column value="{!c.BillingState}" headerValue="Billing State"/>
                    <apex:column value="{!c.Phone}" headerValue="Phone"/>
                </apex:pageBlockTable>
 
            </apex:pageblockSection>
        </apex:pageBlock>
    </apex:form>
 
</apex:page>

and here is my controller : 
public class AccountSelectClassController{
 
    //Our collection of the class/wrapper objects wrapAccount
    public List<wrapAccount> wrapAccountList {get; set;}
    public List<Account> selectedAccounts{get;set;}
 
    public AccountSelectClassController(){
        if(wrapAccountList == null) {
            wrapAccountList = new List<wrapAccount>();
            for(Account a: [select Id, Name,BillingState, Website, Phone from Account limit 10]) {
                // As each Account is processed we create a new wrapAccount object and add it to the wrapAccountList
                wrapAccountList.add(new wrapAccount(a));
            }
        }
    }
 
    public void processSelected() {
    selectedAccounts = new List<Account>();
 
        for(wrapAccount wrapAccountObj : wrapAccountList) {
            if(wrapAccountObj.selected == true) {
                selectedAccounts.add(wrapAccountObj.acc);
            }
        }
    }
 
    // This is our wrapper/container class. In this example a wrapper class contains both the standard salesforce object Account and a Boolean value
    public class wrapAccount {
        public Account acc {get; set;}
        public Boolean selected {get; set;}
 
        public wrapAccount(Account a) {
            acc = a;
            selected = false;
        }
    }
}
When i select on first pageblock it will transfer to another pablock but how can i put another checkbox on second pageblocktable?

Thanks!
AJ
 
Hi,
      trigger AccountDuplicateTrg on Account (before insert,before update)
{
Map<string,Account> accMap = new Map<string,Account>();
set<string> accSet = new set<string>();
    for(Account acc : Trigger.new)
        accSet.add(acc.name);
    for(Account a : [select id,name from Account where name in : accSet])
        accMap.put(a.name,a);
    for(Account acc1 : trigger.new)
        {
        if(accMap.containskey(acc1.name))
           if(Trigger.isInsert){
             acc1.addError('There is another account in the system with this exact name and is a likely duplicate');
           }
           else if(Trigger.isUpdate){
               acc1.addError('There is another Account with the same name as this one. Please navigate to the Account tab');
           
           }
        }
  }

How to apply below senario above trigger updation time

I created a check box named "displayerror". Now in trigger if this check box is true, then throw the error. If check box is false then save the record and have the default value for this check box as true.So when user gets this error he can know the existence of a duplicate account and then in order to save the account he can uncheck the check box which inturn will save the record.

please help me...

 
Hi all,

I have this kind of problem:
when I run tests, they stuck with status "Queued".
I've been waiting for 40-50 min.
User-added image

Thanks.
how to create junction object in salesforce
Hi folks,

I wanna create a new record in my maintenance custom  object automatically when the status field of the standard Product object is changed to 'Out of maintenance'. So could any one please help me in writing trigger for the same. 
Hey there ,
I stuck to get version number , i'd managed to get version name n all like 'XYZ..' but what i want is "V1.0 or 1.1 " like this
anybody there ???
 
Hi,

how to view the excel file preview in visualforce page,Is this possible? kindly give any example or code

Thanks.

 

I'm wondering is it possible to create Excel or CSV file in apex code (as attachment) is it possible ? currently i only see it works with VF page, but i'm looking to do it in apex code not using vf page, I don't see any options.

 

Any help is appreciated.

 

Thanks

Ram

 

  • December 29, 2011
  • Like
  • 0

Hello,

 

I want to delete 500+ custom fields. Is there any solution to mass remove custom fields? I have tried with metadata Api using below code. But it gives me below error.

 

Object with id:04s900000037qo4AAA is InProgress
Error status code: INVALID_CROSS_REFERENCE_KEY
Error message: In field: members - no CustomField named Custom_Field__c found
Object with id:04s900000037qo4AAA is Error

 

Below is the code:

 


    public void deleteCustomField(String fullname) throws Exception
    {
        CustomField customField = new CustomField();
        customField.setFullName(fullname);
        
        UpdateMetadata updateMetadata = new UpdateMetadata();
        updateMetadata.setMetadata(customField);
        updateMetadata.setCurrentName(fullname);
        
        AsyncResult[] asyncResults  = metadataConnection.delete(new Metadata[] {customField});
 
        long waitTimeMilliSecs = ONE_SECOND;
 
        do
        {
            printAsyncResultStatus(asyncResults);
            waitTimeMilliSecs *= 2;
            Thread.sleep(waitTimeMilliSecs);
            asyncResults = metadataConnection.checkStatus(new String[]{asyncResults[0].getId()});
        } while (!asyncResults[0].isDone());
 
        printAsyncResultStatus(asyncResults);
    }

 


    private void printAsyncResultStatus(AsyncResult[] asyncResults) throws Exception {
        if (asyncResults == null || asyncResults.length == 0 || asyncResults[0] == null) {
            throw new Exception("The object status cannot be retrieved");
        }

        AsyncResult asyncResult = asyncResults[0]; //we are creating only 1 metadata object

        if (asyncResult.getStatusCode() != null) {
            System.out.println("Error status code: " +
                    asyncResult.getStatusCode());
            System.out.println("Error message: " + asyncResult.getMessage());
        }

        System.out.println("Object with id:" + asyncResult.getId() + " is " +
            asyncResult.getState());
    }

 

Is there any other solution (any app) to removing custom fields?

 

Thanks in advance,

 

Dhaval Panchal