• rohitash yadav
  • NEWBIE
  • 30 Points
  • Member since 2016

  • Chatter
    Feed
  • 0
    Best Answers
  • 0
    Likes Received
  • 1
    Likes Given
  • 14
    Questions
  • 4
    Replies
Hi All,

I need to export salesforce objects data in to Mysql database on nightly basis.

I want to run a cron job on php server once in a day and export custom object data from salesforce using curl.

What is the best way to achieve this?

Thanks,
Rohitash
Hi,

I want to create a e-commerce website with salesforce. Can anyone help me.

Thanks,
Rohitash
Hi All,

I have created multiple checkbox from selectoption. Now I want to submit the form and filter record based on selected checkbox.

Visualforce code:
 
<apex:selectCheckboxes value="{!checkboxSelections}" >
  <apex:selectOptions value="{!MyCheckboxes}"  >
     <apex:actionSupport event="onclick" action="{!getSelectedOrder}" /> 
  </apex:selectOptions>
</apex:selectCheckboxes>
APex code:
 
public PageReference getSelectedOrder() {
     system.debug('yadav');
     return null;
}

public list<string> checkboxSelections {get;set;}  //holds the values of the selected checkboxes

public list<selectOption> getMyCheckboxes(){
    system.debug('rohiatsh');
    //create list of checkboxes
    list<selectOption> myOptions = new list<selectOption>();
    for(integer i=0;i<5;i++){
    myOptions.add(new selectOption(string.valueof(i),string.valueof(i)));
     } 
    return myOptions;
 }


When I click on any chekbox then getSelectedOrder is not getting called. Can anyone help me.
Hi,

I have upgraded from desk.com to Salesforce Service Cloud. How can I migrate all data like macros, RFQ in to my Salesforce Service Cloud account.

Please suggest!

Thanks,
Rohitash Singh Yadav
Hi All,

I am using Desk.com to manage and reply to customer inquires that include attachments, now I have upgraded to salesforce service cloud. I want to send an automated email to the contact on creating a case or commenting on any case. When any contact person reply to that email then the response will be also display under that particular case. How can I achieve this task like desk.com case management feature.

Thanks,
Rohitash Singh Yadav
Hi,

I am using an <apex:iframe src="/001/e" scrolling="true" id="theIframe"/> tag in my visualforce page but it is showing Load denied by X-Frame-Options: https://eu6.salesforce.com/001/e does not permit cross-origin framing. error .

Can anyone help me to include standard page in visualforce page.

Thanks,
Rohitash
Hi,

I need to create a custom field in contact. I am using an REST api to create/update contact so I want to create a text field in contact object dynamically through SOQL query.

Thanks,
Rohitash
Hi,

I need to show a list of those leads on which any task or call is created. I have wrote the following query but it is not working.

Select Id, Name from Lead where Id IN (SELECT Who.Id FROM Task where Who.Type='Lead') limit 10

Can anyone help me?

Thanks,
Rohitash
Hi,

I have create a visualforce page with javascript remoting and I am using jquery template plugin to show list of leads. Now I want to add a delete button into this listing. How can I achieve this??

My visualforce page is :
 
<apex:page controller="LeadsWithoutActivityController" >
    <!-- include jquery API to create a dynamic table with dynamic columns and CSS similar to salesfroce -->
    <apex:includeScript value="https://ajax.googleapis.com/ajax/libs/jquery/1.5.1/jquery.min.js"/> 
    <apex:includeScript value="https://ajax.microsoft.com/ajax/jquery.templates/beta1/jquery.tmpl.min.js"/> 
    <apex:pageBlock >
        <apex:pageBlockSection columns="1" collapsible="false" id="resultPanel"  >
        <!--- dynamic table --->
        <table cellspacing="0" cellpadding="0" border="0" id="searchResults" class="list "> 
            <colgroup span="2"></colgroup>      
            <thead>
                <tr class="headerRow ">
                    <th colspan="1" scope="col" class="headerRow">Name</th>
                    <th colspan="1" scope="col" class="headerRow">View Quote</th>
                    <th colspan="1" scope="col" class="headerRow">Account Name</th>
                    <th colspan="1" scope="col" class="headerRow">Opportunity Amount</th>
                    <th colspan="1" scope="col" class="headerRow">Quote No</th>
                    <th colspan="1" scope="col" class="headerRow">Date Created</th>
                </tr>
            </thead>
            <tbody />   
        </table> 
        <br/>
        <button type="button" onclick="getCall('previous')">Previous</button>   &nbsp;&nbsp;&nbsp;&nbsp;
        <button type="button" onclick="getCall('next')">Next</button>  &nbsp;&nbsp;&nbsp;&nbsp;
        <div id="responseErrors"></div>
        </apex:pageBlockSection>
    </apex:pageBlock>

    <!-- dynamic column mapping with javascript SObject fields -->
    <script id="leadsTableRowTemplate" type="text/x-jquery-tmpl">
        <tr onfocus="if (window.hiOn){hiOn(this);}" onblur="if (window.hiOff){hiOff(this);}" onmouseout="if (window.hiOff){hiOff(this);} " onmouseover="if (window.hiOn){hiOn(this);} " class="dataRow even  first">
            <td class="dataCell">${Name}</td>
            <td class="dataCell">${Site_quote_no__c}</td>
            <td class="dataCell">${Account__c}</td>
            <td class="dataCell">${Opportunity_Amount__c}</td>
            <td class="dataCell">${Site_quote_no__c}</td>
            <td class="dataCell">${CreatedDate}</td>
        </tr>
    </script>
    <script type="text/javascript">
        var objectValue;
        var pageNumber =0;
        var searchValue;
        
        //Method calls from search button to call server method   
        function getRemoteCall() {
            var markup = "";
            var arrTableHeader = [];
            pageNumber=0;

            Visualforce.remoting.Manager.invokeAction(
                '{!$RemoteAction.LeadsWithoutActivityController.RemoteCall}',
                function(result, event){
                    if (event.status && event.result) {
                        pageNumber=1;

                        //dynamic header creation
                        refreshData(event.result.rowList);
                    } else if (event.type === 'exception') {
                        document.getElementById("responseErrors").innerHTML = event.message;
                    } else {
                        document.getElementById("responseErrors").innerHTML = event.message;
                    }
                },
                {escape: true}
            );
        }

        //append data to search table via jquery tamplates
        function refreshData(data){
            $("#searchResults tbody").html('');
            $.each(data, function () {
                $("#leadsTableRowTemplate" ).tmpl(this).appendTo( "#searchResults tbody" );
            });
        }

        //Methods for paginations
        function getCall(buttonType){
            if(buttonType=='next' ){
                pageNumber =  pageNumber +1 ;
            } else if(buttonType=='previous' ){
                if( pageNumber >=2){
                    pageNumber =  pageNumber -1 ;
                }
            }

            Visualforce.remoting.Manager.invokeAction(
                '{!$RemoteAction.LeadsWithoutActivityController.RemoteCallPagaination}',
                buttonType,pageNumber,
                function(result, event){
                    if (event.status && event.result) {
                        refreshData(event.result);
                    } else if (event.type === 'exception') {
                        document.getElementById("responseErrors").innerHTML = event.message;
                    } else {
                        document.getElementById("responseErrors").innerHTML = event.message;
                    }
                },
                {escape: true}
            );
        }

        function createHeaderMarkup() {
            return ("<th >${colName}</th>");
        }
        function createHeader(colName) {
            return ({ 'colName': colName });
        }
        getRemoteCall();
    </script>
</apex:page>



Thanks,
Rohitash

 
Hi

I write a apex class to insert objects/child objects. This class is called through rest api in php.
 
@RestResource(urlMapping='/FieldCase/*')
global with sharing class RESTCaseController {
    @HttpPost
    global static string updateCase() {
        String requestBody = RestContext.request.requestBody.toString();

        Map<String, Object> root = (Map<String, Object>)JSON.deserializeUntyped(requestBody);
        List<Object> records = (List<Object>)root.get('records');
        List<Lead> totLeads = new List<Lead>();
        List<Opportunity> totOppor = new List<Opportunity>();
		for (Object record : records) {
            Map<String, Object> i = (Map<String, Object>)record;
            Map<String, Object> item = (Map<String, Object>)i.get('quote');
			Quote__c[] exQuote = [Select ID, Quote_no__c from Quote__c where Site_Quote_Id__c =:Integer.valueof(item.get('id')) LIMIT 1];
            if(exQuote.size() == 0){
                // check account and create if not exists
                Map<String, Object> accountData = (Map<String, Object>)i.get('accountData');
                Id quoteAccountId = null;
				quoteAccountId = createAccount(accountData);
                system.debug('quoteAccountId=='+quoteAccountId);

                Map<String, Object> contactData = (Map<String, Object>)i.get('contactData');
                ID quoteContactId = null;
				quoteContactId = createContact(contactData,quoteAccountId);
                system.debug('quoteContactId=='+quoteContactId);

                // insert quote
                Map<String, Object> quoteData = (Map<String, Object>)i.get('quote');
                //Object quoteData = (Object)i.get('quote');
                Quote__c qut = new Quote__c();
                Id quoteId = NULL;
                qut.Account__c = quoteAccountId;
                qut.Contact__c = quoteContactId;
                qut.Created_Date__c = DateTime.Valueof((String)quoteData.get('created_date')); // (Datetime)quoteData.get('created_date');
                if(Integer.valueof(quoteData.get('quote_print')) == 1)
                	qut.Printed__c = true;

                if(Integer.valueof(quoteData.get('quote_emb')) == 1)
                	qut.Embr__c = true;

                if(Integer.valueof(quoteData.get('quote_digi')) == 1)
                	qut.digi__c = true;

                if(Integer.valueof(quoteData.get('quote_trans')) == 1)
                	qut.Transfer__c = true;

                if(Integer.valueof(quoteData.get('quote_names')) == 1)
                	qut.Names__c = true;

                if(Integer.valueof(quoteData.get('user_exists')) == 1)
                	qut.Existing_user__c = true;
                else
                    qut.New_User__c = true;

				qut.Name = (String)quoteData.get('quote_no');
                qut.Quote_no__c = Integer.valueof(quoteData.get('quote_no'));

                Contact[] salespr = [Select ID, Name from Contact where Site_User_Id__c =:Integer.valueof(quoteData.get('assigned_staff_id')) LIMIT 1];
                if(salespr.size() >= 0)
					qut.Sales_person__c = salespr[0].ID;

				qut.Shirts__c = Integer.valueof(quoteData.get('tot_qty'));
                qut.Site_Quote_Id__c = Integer.valueof(quoteData.get('id'));
                qut.Site_Quote_Parent_Id__c = Integer.valueof(quoteData.get('parent_quote_id'));
                qut.Value__c = Integer.valueof(quoteData.get('value'));
                insert qut;
				quoteId = qut.Id;

                if( Integer.valueof(quoteData.get('user_orderd_before')) == 0 ){
                    // check or create leads
                    Lead[] exLeads = [Select ID, Site_Quote_Id__c from Lead where Site_Quote_Id__c =:Integer.valueof(item.get('id')) LIMIT 1];
					if(exLeads.size() == 0){
                        Lead ld = new Lead();
                        ld.Email = (String)quoteData.get('email');
                        ld.First_Name__c = (String)quoteData.get('first_name');
                        ld.Last_Name__c = (String)quoteData.get('family_name');
                        ld.Status = 'Open - Not Contacted';
                        ld.Phone = (String)quoteData.get('telephone');
                        ld.LeadSource = 'Web';
                        ld.Opportunity_Amount__c = Integer.valueof(quoteData.get('value'));
                        ld.Account__c = quoteAccountId;
                        if(salespr.size() >= 0)
							ld.Sales_person__c = salespr[0].ID;
                        
                        ld.Site_Quote_Id__c = Integer.valueof(quoteData.get('id'));
                        ld.Site_quote_no__c = Integer.valueof(quoteData.get('quote_no'));
                        ld.Site_User_Id__c = Integer.valueof(quoteData.get('user_id'));
                        ld.Quantity__c = Integer.valueof(quoteData.get('tot_qty'));
                        if(Integer.valueof(quoteData.get('quote_print')) == 1)
                            ld.Printed__c = true;
        
                        if(Integer.valueof(quoteData.get('quote_emb')) == 1)
                            ld.Embroidery__c = true;
        
                        if(Integer.valueof(quoteData.get('quote_digi')) == 1)
                            ld.Digital__c = true;
        
                        if(Integer.valueof(quoteData.get('quote_trans')) == 1)
                            ld.Transfer__c = true;
        
                        if(Integer.valueof(quoteData.get('quote_names')) == 1)
                            ld.Names__c = true;
        
                        if(Integer.valueof(quoteData.get('user_exists')) == 1)
                            ld.Existing_user__c = true;
                        else
                            ld.New_User__c = true;
                        
                        //ld.User_Activated__c
                        ld.Is_Ordered__c = false;
                        if(Integer.valueof(quoteData.get('is_ordered')) == 1)
                            ld.Is_Ordered__c = true;
                        totLeads.add(ld);
						//insert ld;
                    }
                } else {
                    // check or create opportunity
                    Opportunity[] exOppor = [Select ID, Site_Quote_Id__c from Opportunity where Site_Quote_Id__c =:Integer.valueof(item.get('id')) LIMIT 1];
            		if(exOppor.size() == 0){
                        Opportunity oppor = new Opportunity();
                        oppor.Name = 'Quote no. '+(String)quoteData.get('quote_no');
                        oppor.AccountId = quoteAccountId;
                        oppor.Contact__c = quoteContactId;
                        oppor.CloseDate = Date.Valueof((String)quoteData.get('created_date')).addDays(30);
                        oppor.LeadSource = 'Web';
                        oppor.TotalOpportunityQuantity = Integer.valueof(quoteData.get('tot_qty'));
                        oppor.Site_Quote_Id__c = Integer.valueof(quoteData.get('id'));
                        oppor.Site_Salesperson_Id__c = Integer.valueof(quoteData.get('assigned_staff_id'));
                        oppor.StageName = 'Proposal/Price Quote';
                        oppor.Amount = Integer.valueof(quoteData.get('value'));
                        if(salespr.size() >= 0)
							oppor.Sales_person__c = salespr[0].ID;
                        totOppor.add(oppor);
                        //insert oppor;
                    }
                }

                // inserting quote products
                List<Object> quoteProducts = (List<Object>)quoteData.get('quoteProducts');

                for (Object quoteProduct : quoteProducts) {
                    Map<String, Object> p = (Map<String, Object>) quoteProduct;
                    // insert quote products
                    saveQuoteProduct(p,quoteId);
                }
            }
        }
        insert totLeads;
        insert totOppor;
        return 'data';
    }

    private static Void saveQuoteProduct(Map<String, Object> quoteProductData,Id quoteId){
        Id quoteProductId = null;
        Quote_Products__c qp = new Quote_Products__c();
        if(Integer.valueof(quoteProductData.get('brand_id')) != 0){
            Brand__c[] brand = [Select Id from Brand__c where Brand_Site_Id__c =:Integer.valueof(quoteProductData.get('brand_id')) LIMIT 1];
            if(brand.size() > 0)
                qp.Brand__c = brand[0].Id;
        }
        qp.Customised_Colour_hex_value__c = (String)quoteProductData.get('customised_colour_hex');
        qp.Customised_Colour_name__c = (String)quoteProductData.get('customised_colour_name');
        qp.Plain_Item__c = false;
        if(Integer.valueof(quoteProductData.get('plain_item')) == 1)
            qp.Plain_Item__c = true;
        
        if(Integer.valueof(quoteProductData.get('product_category_id')) != 0){
            qp.Site_Category_Id__c = Integer.valueof(quoteProductData.get('product_category_id'));
            Product_Category__c[] prdcat = [Select Id from Product_Category__c where Site_Category_Id__c =:Integer.valueof(quoteProductData.get('product_category_id')) LIMIT 1];
            if(prdcat.size() > 0)
                qp.Product_Category__c = prdcat[0].Id;
        }
        
        qp.Product_Code__c = (String)quoteProductData.get('pencarrie_lnLine');
        qp.Name = qp.Product_Name__c = (String)quoteProductData.get('name');
        if(Integer.valueof(quoteProductData.get('root_category_id')) != 0){
            qp.Site_Root_Category_Id__c = Integer.valueof(quoteProductData.get('root_category_id'));
            Product_Category__c[] prdrootcat = [Select Id from Product_Category__c where Site_Category_Id__c =:Integer.valueof(quoteProductData.get('root_category_id')) LIMIT 1];
            if(prdrootcat.size() > 0)
                qp.Product_Root_Category__c = prdrootcat[0].Id;
        }
        
        qp.Quote__c = quoteId;
        qp.Site_Brand_Id__c = Integer.valueof(quoteProductData.get('brand_id'));
        qp.Site_Customised_Colour__c = Integer.valueof(quoteProductData.get('customised_colour'));
        qp.site_quote_id__c = Integer.valueof(quoteProductData.get('quote_id'));
        qp.Site_Quote_Product_Id__c = Integer.valueof(quoteProductData.get('product_id'));
        qp.Site_SessionKey__c = Integer.valueof(quoteProductData.get('sessionKey'));
        qp.tot_qty__c = Integer.valueof(quoteProductData.get('total_qty'));

        insert qp;
        quoteProductId = qp.Id;
		// insert quote product sizes

        List<Object> quoteProductSizesNew = (List<Object>)quoteProductData.get('productSizes');
        List<Quote_Product_Size__c> totqps = new List<Quote_Product_Size__c>();
        for (Object quoteProductSize : quoteProductSizesNew) {
            Map<String, Object> quotePrdSizeData = (Map<String, Object>) quoteProductSize;
            // insert quote products
            Quote_Product_Size__c qps = new Quote_Product_Size__c();
            qps = saveQuoteProductSize(quotePrdSizeData,quoteId,quoteProductId);
            totqps.add(qps);
        }
        insert totqps;

        if( !qp.Plain_Item__c ){
            Map<String, Object> data = (Map<String, Object>) quoteProductData.get('data');
            List<Object> quoteProductPositions = (List<Object>)data.get('positions');
            List<Quote_Product_Positions__c> totqpp = new List<Quote_Product_Positions__c>();
            for (Object quoteProductPosition : quoteProductPositions) {
                Map<String, Object> quoteProductPositionData = (Map<String, Object>) quoteProductPosition;
                // insert quote products positions
                Quote_Product_Positions__c qpp = new Quote_Product_Positions__c();
                qpp = saveQuoteProductPosition(quoteProductPositionData,quoteId,quoteProductId);
                totqpp.add(qpp);
            }
            insert totqpp;
        }
        //return qp.Id;
    }

    private static Quote_Product_Size__c saveQuoteProductSize(Map<String, Object> quoteProductSizeData,Id quoteId,Id quoteProductId){
        Quote_Product_Size__c qps = new Quote_Product_Size__c();
        qps.Quantity__c = Integer.valueof(quoteProductSizeData.get('qty'));
        qps.Quote_Id__c = quoteId;
        qps.Name = (String)quoteProductSizeData.get('description');
        qps.Quote_Products__c = quoteProductId ; //Integer.valueof(quoteProductSizeData.get('quoteProductId'));
        qps.Site_Quote_Id__c = Integer.valueof(quoteProductSizeData.get('quote_id'));
        qps.Quote_Products__c = quoteProductId;
        qps.Site_Quote_Product_Id__c = Integer.valueof(quoteProductSizeData.get('product_id'));
        qps.Site_Quote_Id__c = Integer.valueof(quoteProductSizeData.get('quote_id'));
        qps.Site_SessionKey__c = Integer.valueof(quoteProductSizeData.get('sessionKey'));
        qps.Site_Size_Id__c = Integer.valueof(quoteProductSizeData.get('size_id'));
        qps.Size_Name__c = (String)quoteProductSizeData.get('description');
        //insert qps;
        return qps;
    }
    
    private static Quote_Product_Positions__c saveQuoteProductPosition(Map<String, Object> quoteProductSizeData,Id quoteId,Id quoteProductId){
        Quote_Product_Positions__c qpp = new Quote_Product_Positions__c();
        
        qpp.Customised_Position__c = (String)quoteProductSizeData.get('customised_position_name');
        qpp.Name = (String)quoteProductSizeData.get('customised_position_name');
        qpp.Quote__c = quoteId;
        qpp.Quote_Products__c = quoteProductId;

        String customType = (String)quoteProductSizeData.get('custom_type');
        qpp.Custom_Type__c = customType;
        if( customType == 'artwork' ){
			qpp.Site_Artwork__c = (String)quoteProductSizeData.get('artwork');
            qpp.Site_ColorName__c = (String)quoteProductSizeData.get('colorName');
            qpp.Site_ColorOpt__c = (String)quoteProductSizeData.get('colorOpt');
            qpp.Site_Colorvalues__c = (String)quoteProductSizeData.get('colorValues');
        } else {
            qpp.Site_printname__c = (String)quoteProductSizeData.get('printname');
            qpp.Site_printNameOpt__c = (String)quoteProductSizeData.get('printNameOpt');
            qpp.Site_printnameQty__c = Integer.valueof(quoteProductSizeData.get('printnameQty'));
        }
        qpp.Site_Customised_Position__c = Integer.valueof(quoteProductSizeData.get('customised_position'));
        //qpp.Site_Num_Colour__c
        qpp.Site_positionQty__c = Integer.valueof(quoteProductSizeData.get('positionQty'));
        String print_type = (String)quoteProductSizeData.get('print_type');
        qpp.Print_Type__c = print_type;
        qpp.Site_Print_type_Option__c = print_type;
        qpp.Site_Quote_Id__c = Integer.valueof(quoteProductSizeData.get('quote_id'));
        qpp.Site_Quote_Product_Id__c = Integer.valueof(quoteProductSizeData.get('product_id'));
        qpp.Site_SessionKey__c = Integer.valueof(quoteProductSizeData.get('sessionKey'));
        //insert qpp;
        return qpp;
    }

    private static ID createAccount(Map<String, Object> accountData){
        Id quoteAccountId = null;
        if(Integer.valueof(accountData.get('Site_Company_Id__c')) != 0){
            Account[] account = [Select ID, Name from Account where Site_Company_Id__c =:Integer.valueof(accountData.get('Site_Company_Id__c')) LIMIT 1];
            if(account.size() == 0){
                Account acc = new Account();
                acc.Name = (String)accountData.get('Name');
                acc.Site_Company_Id__c = Integer.valueof(accountData.get('Site_Company_Id__c'));
                acc.Site_User_Id__c = 0;
                insert acc;
                quoteAccountId = acc.Id;
            }else{
                quoteAccountId = account[0].ID;
            }
        } else {
            Account[] account = [Select ID, Name from Account where Site_User_Id__c =:Integer.valueof(accountData.get('Site_User_Id__c')) LIMIT 1];
            if(account.size() == 0){
                Account acc = new Account();
                acc.Name = (String)accountData.get('Name');
                acc.Site_Company_Id__c = 0;
                acc.Site_User_Id__c = Integer.valueof(accountData.get('Site_User_Id__c'));
                insert acc;
                quoteAccountId = acc.Id;
            }else{
                quoteAccountId = account[0].ID;
            }
        }
    	return quoteAccountId;
    }

    private static ID createContact(Map<String, Object> contactData,Id quoteAccountId){
        ID quoteContactId = null;
        if(Integer.valueof(contactData.get('Site_User_Id__c')) != 0){
            Contact[] contact = [Select ID, Name from Contact where Site_User_Id__c =:Integer.valueof(contactData.get('Site_User_Id__c')) LIMIT 1];
            if(contact.size() == 0){
                Contact con = new Contact();
                con.Firstname = (String)contactData.get('Firstname');
                con.Lastname = (String)contactData.get('Lastname');
                con.Email = (String)contactData.get('Email');
                con.Phone = (String)contactData.get('Phone');
                con.Site_User_Id__c = Integer.valueof(contactData.get('Site_User_Id__c'));
                
                if(quoteAccountId != null)
                    con.AccountId = quoteAccountId;

                if(Integer.valueof(contactData.get('sales_person__c')) != 0 ){
                    Contact[] salcon = [Select ID, Name from Contact where Site_User_Id__c =:Integer.valueof(contactData.get('sales_person__c')) LIMIT 1];
                    if(salcon.size()>0){
                        con.sales_person__c = salcon[0].ID;
                    }
                }
                insert con;
                quoteContactId = con.Id;
            }else{
                quoteContactId = contact[0].ID;
            }
        }
        return quoteContactId;
    }
}


What I need to do optimize this class,reduce DML operations and SOQL statements? 

Thanks,
Rohitash Yadav
Hi,

I have a website in php. If any order place on my website then I want to save all order related information to salesforce account. What is the best way to do this ?  How to avoid governer limits for this also?

Thanks,
Rohitash

 
Hi,

I have added a filter on records. It is not working when I add checkbox in the list.

My visualforce Page
 
<apex:page standardController="Line_Item__c" extensions="LineItemPackagesExtensions" recordSetVar="lineitems" >
	<apex:pageBlock title="Search for Packages">
        	<apex:outputLabel >Packages Category</apex:outputLabel>
		<apex:inputField value="{!prdcat.Product_Category__c}" >
                	<apex:actionSupport event="onchange" rerender="packagesList" action="{!filterPackages}"/>
		</apex:inputField>
            	<apex:outputPanel id="packagesList">
                	<apex:pageBlockTable value="{!Packages}" var="a">
                    		<apex:column value="{!a.Name}"/>
                    		<apex:column value="{!a.Product_Category__c}"/>
                    		<apex:column value="{!a.Cost__c}"/>
                    		<apex:column value="{!a.Stay__c}"/>
                    		<apex:column value="{!a.Activity__c}"/>
                    		<apex:column value="{!a.Description__c}"/>
                	</apex:pageBlockTable>
           	</apex:outputPanel>
        </apex:pageBlock>
</apex:page>

Apex code is:
 
public class LineItemPackagesExtensions {

    public Package__c pkgs;
    public List<Package__c> Packages { get; set; }
    public Package__c prdcat{get;set;}
    


    public LineItemPackagesExtensions(ApexPages.StandardSetController controller) {
        Packages = [SELECT Name,Product_Category__c,Cost__c,Stay__c,Activity__c,Description__c FROM Package__c ];
    }

    public List<Package__c> getPackages(){
        Packages = [SELECT Name,Product_Category__c,Cost__c,Stay__c,Activity__c,Description__c FROM Package__c ];
        return Packages;
    }
    
    public void filterPackages() {
    	Packages = [SELECT Name,Product_Category__c,Cost__c,Stay__c,Activity__c,Description__c FROM Package__c 
           where Product_Category__c=:prdcat.Product_Category__c ];
    }

}

Thanks,
Rohitash 
Hi,

I have some records with checkbox for each record. When I checked any checkbox then I need to add new row to another table. In the new row I also need some input boxes with some actions. After that I need to save all these records.

My Visualforce page is :
 
<apex:page standardController="Line_Item__c" extensions="LineItemPackagesExtensions" recordSetVar="lineitems" >
	<apex:includeScript value="//ajax.googleapis.com/ajax/libs/jquery/1.11.0/jquery.min.js"/>
	<script type="text/javascript">
		function addPackage(pkgid){
			Visualforce.remoting.Manager.invokeAction(
		                '{!$RemoteAction.LineItemPackagesExtensions.getPackage}',
                		pkgid,
		                function(result, event){
                			$('#OpporPackages tr:last').after('<tr class="child"><td>Remove</td><td>Add</td><td>'+result.Name+'<\/td><td>'+result.Product_Category__c+'<\/td><td>'+result.Cost__c+'<\/td><td><apex:inputText value="{!result.Cost__c}"/><\/td><td>'+result.Name+'<\/td></tr>');
                    			alert(result.Name)
		                },
		                {escape: true}
            		);
		}
	</script>
	<apex:form >
        	<apex:pageBlock title="Selected Packages">
            		<apex:pageBlockButtons location="top">
				<apex:commandButton value="Save" action="{!save}"/>
                		<apex:commandButton value="Cancel" action="{!cancel}"/>
            		</apex:pageBlockButtons>
            		<table class="list" id="OpporPackages">
                		<thead>
                    			<tr>
                	       			<th></th>
		                        	<th></th>
                        			<th>Product Name</th>
		                        	<th>Product Category</th>
                		        	<th>Price</th>
		                        	<th>Final Price</th>
                		        	<th>No of Days</th>
		                        	<th>No of People</th>
		                        	<th>No of Male</th>
		                        	<th>No of Female</th>
		                        	<th>Total Price</th>
		                        	<th>Comments</th>
					</tr> 
	                	</thead>
        	        	<tbody>
                	    		<tr></tr>
		                </tbody>
        		</table>
        	</apex:pageBlock>
		<apex:pageBlock title="Search for Packages">
			<apex:outputPanel id="packagesList">
				<apex:pageBlockTable value="{!Packages}" var="a">
					<apex:column >
						<apex:actionsupport event="onclick" />
						<apex:inputCheckbox value="{!a.id}" onclick="addPackage('{!a.id}')"/>
					</apex:column>
					<apex:column value="{!a.Name}"/>
					<apex:column value="{!a.Product_Category__c}"/>
                    			<apex:column value="{!a.Cost__c}"/>
                    			<apex:column value="{!a.Stay__c}"/>
                    			<apex:column value="{!a.Activity__c}"/>
                    			<apex:column value="{!a.Description__c}"/>
                		</apex:pageBlockTable>
           		</apex:outputPanel>
        	</apex:pageBlock>
    	</apex:form>
</apex:page>

Apex Class is:
global with sharing class LineItemPackagesExtensions {

    public Package__c pkgs;
    public List<Package__c> Packages { get; set; }
    public static Package__c packageDetail{ get; set; }
    public String params{get;set;}
    public Package__c prdcat{get;set;}
    
   
    public LineItemPackagesExtensions(ApexPages.StandardSetController controller) {
        prdcat = new Package__c();
        Packages = [SELECT Name,Product_Category__c,Cost__c,Stay__c,Activity__c,Description__c FROM Package__c ];
    }

    @RemoteAction
    global static Package__c getPackage(String pkgid){
        packageDetail = [SELECT Name,Product_Category__c,Cost__c,Stay__c,Activity__c,Description__c FROM Package__c 
            where id=:pkgid ];
        return packageDetail;
    }
    
    public  List<Package__c> getPackages(){
        Packages = [SELECT Name,Product_Category__c,Cost__c,Stay__c,Activity__c,Description__c FROM Package__c ];
        return Packages;
    }
}
I don't know how to add text box in javascript code in visualforce page. Please help to achieve this.

Thanks,
Rohitash
Hi

I have some records listing on visualforce page . I want to filter these records based on selected value of custom picklist. I am not able to get selected value of this picklist in apex class.

My visualforce page is:
 
<apex:page standardController="Line_Item__c" extensions="LineItemPackagesExtensions" recordSetVar="lineitems" >
	<apex:pageBlock title="Search for Packages">
        	<apex:outputLabel >Packages Category</apex:outputLabel>
		<apex:inputField value="{!prdcat.Product_Category__c}" >
                	<apex:actionSupport event="onchange" rerender="packagesList" action="{!filterPackages}"/>
		</apex:inputField>
            	<apex:outputPanel id="packagesList">
                	<apex:pageBlockTable value="{!Packages}" var="a">
                    		<apex:column value="{!a.Name}"/>
                    		<apex:column value="{!a.Product_Category__c}"/>
                    		<apex:column value="{!a.Cost__c}"/>
                    		<apex:column value="{!a.Stay__c}"/>
                    		<apex:column value="{!a.Activity__c}"/>
                    		<apex:column value="{!a.Description__c}"/>
                	</apex:pageBlockTable>
           	</apex:outputPanel>
        </apex:pageBlock>
</apex:page>

Apex class is:
 
public class LineItemPackagesExtensions {

    public Package__c pkgs;
    public List<Package__c> Packages { get; set; }
    public Package__c prdcat{get;set;}
    


    public LineItemPackagesExtensions(ApexPages.StandardSetController controller) {
        Packages = [SELECT Name,Product_Category__c,Cost__c,Stay__c,Activity__c,Description__c FROM Package__c ];
    }

    public List<Package__c> getPackages(){
        Packages = [SELECT Name,Product_Category__c,Cost__c,Stay__c,Activity__c,Description__c FROM Package__c ];
        return Packages;
    }
    
    public void filterPackages() {
    	Packages = [SELECT Name,Product_Category__c,Cost__c,Stay__c,Activity__c,Description__c FROM Package__c 
           where Product_Category__c=:prdcat.Product_Category__c ];
    }

}

When I change the value of picklist it throws the following error

Attempt to de-reference a null object
Error is in expression '{!filterPackages}' in page addopportunitylineitem1: Class.LineItemPackagesExtensions.filterPackages: line 35, column 1


Please help to achieve this.
Thanks
Rohitash
Hi,

I need to show a list of those leads on which any task or call is created. I have wrote the following query but it is not working.

Select Id, Name from Lead where Id IN (SELECT Who.Id FROM Task where Who.Type='Lead') limit 10

Can anyone help me?

Thanks,
Rohitash
Hi,

I have a website in php. If any order place on my website then I want to save all order related information to salesforce account. What is the best way to do this ?  How to avoid governer limits for this also?

Thanks,
Rohitash

 
Hi,

I have some records with checkbox for each record. When I checked any checkbox then I need to add new row to another table. In the new row I also need some input boxes with some actions. After that I need to save all these records.

My Visualforce page is :
 
<apex:page standardController="Line_Item__c" extensions="LineItemPackagesExtensions" recordSetVar="lineitems" >
	<apex:includeScript value="//ajax.googleapis.com/ajax/libs/jquery/1.11.0/jquery.min.js"/>
	<script type="text/javascript">
		function addPackage(pkgid){
			Visualforce.remoting.Manager.invokeAction(
		                '{!$RemoteAction.LineItemPackagesExtensions.getPackage}',
                		pkgid,
		                function(result, event){
                			$('#OpporPackages tr:last').after('<tr class="child"><td>Remove</td><td>Add</td><td>'+result.Name+'<\/td><td>'+result.Product_Category__c+'<\/td><td>'+result.Cost__c+'<\/td><td><apex:inputText value="{!result.Cost__c}"/><\/td><td>'+result.Name+'<\/td></tr>');
                    			alert(result.Name)
		                },
		                {escape: true}
            		);
		}
	</script>
	<apex:form >
        	<apex:pageBlock title="Selected Packages">
            		<apex:pageBlockButtons location="top">
				<apex:commandButton value="Save" action="{!save}"/>
                		<apex:commandButton value="Cancel" action="{!cancel}"/>
            		</apex:pageBlockButtons>
            		<table class="list" id="OpporPackages">
                		<thead>
                    			<tr>
                	       			<th></th>
		                        	<th></th>
                        			<th>Product Name</th>
		                        	<th>Product Category</th>
                		        	<th>Price</th>
		                        	<th>Final Price</th>
                		        	<th>No of Days</th>
		                        	<th>No of People</th>
		                        	<th>No of Male</th>
		                        	<th>No of Female</th>
		                        	<th>Total Price</th>
		                        	<th>Comments</th>
					</tr> 
	                	</thead>
        	        	<tbody>
                	    		<tr></tr>
		                </tbody>
        		</table>
        	</apex:pageBlock>
		<apex:pageBlock title="Search for Packages">
			<apex:outputPanel id="packagesList">
				<apex:pageBlockTable value="{!Packages}" var="a">
					<apex:column >
						<apex:actionsupport event="onclick" />
						<apex:inputCheckbox value="{!a.id}" onclick="addPackage('{!a.id}')"/>
					</apex:column>
					<apex:column value="{!a.Name}"/>
					<apex:column value="{!a.Product_Category__c}"/>
                    			<apex:column value="{!a.Cost__c}"/>
                    			<apex:column value="{!a.Stay__c}"/>
                    			<apex:column value="{!a.Activity__c}"/>
                    			<apex:column value="{!a.Description__c}"/>
                		</apex:pageBlockTable>
           		</apex:outputPanel>
        	</apex:pageBlock>
    	</apex:form>
</apex:page>

Apex Class is:
global with sharing class LineItemPackagesExtensions {

    public Package__c pkgs;
    public List<Package__c> Packages { get; set; }
    public static Package__c packageDetail{ get; set; }
    public String params{get;set;}
    public Package__c prdcat{get;set;}
    
   
    public LineItemPackagesExtensions(ApexPages.StandardSetController controller) {
        prdcat = new Package__c();
        Packages = [SELECT Name,Product_Category__c,Cost__c,Stay__c,Activity__c,Description__c FROM Package__c ];
    }

    @RemoteAction
    global static Package__c getPackage(String pkgid){
        packageDetail = [SELECT Name,Product_Category__c,Cost__c,Stay__c,Activity__c,Description__c FROM Package__c 
            where id=:pkgid ];
        return packageDetail;
    }
    
    public  List<Package__c> getPackages(){
        Packages = [SELECT Name,Product_Category__c,Cost__c,Stay__c,Activity__c,Description__c FROM Package__c ];
        return Packages;
    }
}
I don't know how to add text box in javascript code in visualforce page. Please help to achieve this.

Thanks,
Rohitash
Hi

I have some records listing on visualforce page . I want to filter these records based on selected value of custom picklist. I am not able to get selected value of this picklist in apex class.

My visualforce page is:
 
<apex:page standardController="Line_Item__c" extensions="LineItemPackagesExtensions" recordSetVar="lineitems" >
	<apex:pageBlock title="Search for Packages">
        	<apex:outputLabel >Packages Category</apex:outputLabel>
		<apex:inputField value="{!prdcat.Product_Category__c}" >
                	<apex:actionSupport event="onchange" rerender="packagesList" action="{!filterPackages}"/>
		</apex:inputField>
            	<apex:outputPanel id="packagesList">
                	<apex:pageBlockTable value="{!Packages}" var="a">
                    		<apex:column value="{!a.Name}"/>
                    		<apex:column value="{!a.Product_Category__c}"/>
                    		<apex:column value="{!a.Cost__c}"/>
                    		<apex:column value="{!a.Stay__c}"/>
                    		<apex:column value="{!a.Activity__c}"/>
                    		<apex:column value="{!a.Description__c}"/>
                	</apex:pageBlockTable>
           	</apex:outputPanel>
        </apex:pageBlock>
</apex:page>

Apex class is:
 
public class LineItemPackagesExtensions {

    public Package__c pkgs;
    public List<Package__c> Packages { get; set; }
    public Package__c prdcat{get;set;}
    


    public LineItemPackagesExtensions(ApexPages.StandardSetController controller) {
        Packages = [SELECT Name,Product_Category__c,Cost__c,Stay__c,Activity__c,Description__c FROM Package__c ];
    }

    public List<Package__c> getPackages(){
        Packages = [SELECT Name,Product_Category__c,Cost__c,Stay__c,Activity__c,Description__c FROM Package__c ];
        return Packages;
    }
    
    public void filterPackages() {
    	Packages = [SELECT Name,Product_Category__c,Cost__c,Stay__c,Activity__c,Description__c FROM Package__c 
           where Product_Category__c=:prdcat.Product_Category__c ];
    }

}

When I change the value of picklist it throws the following error

Attempt to de-reference a null object
Error is in expression '{!filterPackages}' in page addopportunitylineitem1: Class.LineItemPackagesExtensions.filterPackages: line 35, column 1


Please help to achieve this.
Thanks
Rohitash
Hi All,
We are re-building a webstie that used Dynamics CRM as the backend system.  The new website will use Salesforce.  We'll be using Salesforce to store users' login information.  Due to the SF API limit, we want to avoid having to make a call to SF to authenticate users as much as possible.  We are new to Salesforce and would like to hear your opinions/suggestions on how to best accomplish this?  Our website has heavy traffic that will continue to grow so we feel like continuing to increase our API limit is not a good long term solution.