• Gaurav_Srivastava
  • NEWBIE
  • 120 Points
  • Member since 2015

  • Chatter
    Feed
  • 4
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 0
    Questions
  • 17
    Replies
Hi,
I need to print out stickers(addresses) for envelopes to be sent out for campaign members who registered for my campaign (means they have status Registered), so the code below with custom button on campaign generates such list to be printed. However I kind of struggle with "rendered", the bold part of the code causes me troubles, Im getting error Generate_Stickers line 12, column 23: The element type "apex:pageBlockSectionItem" must be terminated by the matching end-tag "</apex:pageBlockSectionItem>"  
What am I doing wrong? Many thanks
<apex:page standardController="Campaign" showHeader="false" applyBodyTag="false" >
      <apex:pageBlock >
          <apex:pageBlockSection columns="3" showHeader="false">
                <apex:repeat value="{!Campaign.CampaignMembers}" var="line" >   
                    <apex:pageBlockSectionItem rendered="{!line.Status="Registered"}" dataStyle="width:33%" labelStyle="width:33%" >
    
                    {!line.Contact.Name}<BR/>
                    {!line.Contact.MailingStreet}<BR/>
                    {!line.Contact.MailingPostalCode} {!line.Contact.MailingCity}<BR/>
                    {!line.Contact.MailingCountry}<BR/>  
                    
                    </apex:pageBlockSectionItem>
                </apex:repeat>
          </apex:pageBlockSection>
      </apex:pageBlock> 
</apex:page>

 
Hello!

Task: I am trying to create pretty much simple visualforce page. Table with 5 columns. Column 1 = Employee name. Column 2-5 = Employee completed courses.

Problem: Faced a problem creating columns for employee courses. These columns should output the TRUE or FALSE value e.g. if employee has completed a course or not. The current implementation looks like:
     
<apex:page standardController="CourseEnrollment__c" recordSetVar="records" id="thePage" cache="false"> 
<apex:form id="theForm"> 
    <apex:pageBlock id="thePageBlock"> 
        <apex:pageBlockTable value="{!records}" var="record" id="thePageBlockTable"> 
            <apex:column >
                <apex:outputField value="{!record.Employee__r.Name}" id="EmployeeNameDOM" /> 
                <apex:facet name="header">Name</apex:facet>
            </apex:column>
            <apex:column>
                <apex:outputText value="{!IF(!record.Course__r.Status == 'Completed','Completed','Expected')}" id="CourseNameDOM" /> 
                <apex:facet name="header">Course status</apex:facet>
            </apex:column>
        </apex:pageBlockTable> 
    </apex:pageBlock> 
</apex:form>
</apex:page>
The main object is CourseEnrollment, Employee and Course are related objects (master-details relation -> http://www.screencast.com/t/nLStStlAjzr)
Code above is just a test, trying to make IF statement work - no luck (also tried to use CONTAINS).

Question:
What is the right way to compare custom objects values on visualforce page? Is it worth to use custom controller, and get all required data already inside the custom class, not to complicate visualforce page structure?

 
Hi all,

looking for Apex syntax how to open a VisualForce page
ie :
 if (field==Case1)
{open visualForce1}
 if (field==Case2)
{open visualForce2}

Many thaks for your assistance.
I have below code to redirect to diffrent page based on user's region, region is a custom field picklist:

{!REQUIRESCRIPT("/soap/ajax/29.0/connection.js")} 
{!REQUIRESCRIPT('/soap/ajax/29.0/apex.js')} 
var x = {!TEXT($User.Region__c)}; 
if(x == 'India'){ 
window.open("/apex/page1"); 

else{ 
window.open("/apex/page2"); 
}

But I am getting "India is not defined" error. Please help me out.

Thanks in advance
Hello,

I continue to recieve a Compile Error when using the APEX Trigger functionalitly.  Below is the error message along with the source code I am using.  Please advise what I am missing here.

Error: Compile Error: Didn't understand relationship 'Line_Items__r' in FROM part of query call. If you are attempting to use a custom relationship, be sure to append the '__r' after the custom relationship name. Please reference your WSDL or the describe call for the appropriate names. at line 4 column 31

trigger DeleteRestrictInvoice on Invoice__c (before delete) {

  // create a list of Invoices in Trigger.oldMap along with their Line Items
  List<Invoice__c> invoices = [Select i.Name, (Select Name From Line_Items__r)
                                 From Invoice__c i
                                Where i.Id IN :Trigger.oldMap.keySet()];

  // loop through the Invoices, attaching errors to those that have Line Items
  for (Invoice__c invoice : invoices) {
    if (!invoice.Line_Items__r.isEmpty()) {
      Trigger.oldMap.get(invoice.id).addError('Cannot delete Invoice with Line Items');
    }
  }
}
 
Hi,
I need to print out stickers(addresses) for envelopes to be sent out for campaign members who registered for my campaign (means they have status Registered), so the code below with custom button on campaign generates such list to be printed. However I kind of struggle with "rendered", the bold part of the code causes me troubles, Im getting error Generate_Stickers line 12, column 23: The element type "apex:pageBlockSectionItem" must be terminated by the matching end-tag "</apex:pageBlockSectionItem>"  
What am I doing wrong? Many thanks
<apex:page standardController="Campaign" showHeader="false" applyBodyTag="false" >
      <apex:pageBlock >
          <apex:pageBlockSection columns="3" showHeader="false">
                <apex:repeat value="{!Campaign.CampaignMembers}" var="line" >   
                    <apex:pageBlockSectionItem rendered="{!line.Status="Registered"}" dataStyle="width:33%" labelStyle="width:33%" >
    
                    {!line.Contact.Name}<BR/>
                    {!line.Contact.MailingStreet}<BR/>
                    {!line.Contact.MailingPostalCode} {!line.Contact.MailingCity}<BR/>
                    {!line.Contact.MailingCountry}<BR/>  
                    
                    </apex:pageBlockSectionItem>
                </apex:repeat>
          </apex:pageBlockSection>
      </apex:pageBlock> 
</apex:page>

 
How to find record type id from without soql in aprx?
Hello Salesforce.com professionals!

I've run into the following situation and need some help in investigation. I have VF page, which consist of tabs. Let's call this page 'MainPage'. Each tab is VF Component.

**************************************************
    <apex:tabPanel switchType="client" value="{!selectedTab}" id="AccountTabPanel" tabClass="activeTab" inactiveTabClass="inactiveTab" >       
        <apex:tab label="{!dealObjectLabel} Details" name="DealDetails" id="tabOne">
            <c:DealDetails value="{!deal}" parentController="{!parentControl}"/>
        </apex:tab>        
        <apex:tab label="Team Members" name="DealTeamMembers" id="tabTwo" disabled="{!dtmDisabled}">
            <c:DealTeamMembers value="{!deal}" parentController="{!parentControl}"/>
        </apex:tab>       
        <apex:tab label="Products" name="DealProducts" id="tabThree" disabled="{!dpDisabled}">
            <c:DealProducts value="{!deal}" parentController="{!parentControl}"/>
        </apex:tab>       
        <apex:tab label="Contacts" name="DealContacts" id="tabFour" disabled="{!dcDisabled}">
            <c:DealContacts value="{!deal}" parentController="{!parentControl}"/>
        </apex:tab>
    </apex:tabPanel>   
    </apex:outputpanel>
**************************************************
Each VF component has its own controller, and it's own custom Save() function. Each VF component calls that corresponding Save() function using jscript. Exaple of Save() function on DealDetails component:

**********************************************
        function saveDetail()
        {     
            commitSave_D(true);
        }

            <apex:actionFunction name="commitSave_D" action="{!doSave}" reRender="ownerSecID,pbs1,pbsNotes,generalerrors" >
                <apex:param name="y_Detail" value="y_Detail" assignTo="{!isFromParent_Detail}" />
            </apex:actionFunction>
**********************************************
There is 'Save and Close' button on the 'MaingPage', which will call its own Save jscript function. This jscript function calls Save jscript functioin on each individual component.
******************************************** Save function on MainPage ************************************
        function saveAllComponents()
        {
            if (!isCurrentlySaving)
            {              
                setButtonStates(true);
                isCurrentlySaving = true;
                errorMessages = "";
                isSavingAll = true;
                saveDetail();
                saveProducts();
                saveContacts();
            }
        }
********************************************
The problem that customer has is ocassional hanging up and timing out of the 'MainPage' when they click on 'Save and Close' button. The question is if it's possible that calling having Saving code in mulitples components and controllers can cause this type of slowdown? Will it be significantly faster if entire Saving code was called from the MainPage?

Thanks!

I am the System Admin for our instance. I am currently developing a visualforce page. The System Admin profile has access to the page and controller.

However when I call my action function I get a "Insufficient Privileges" error message.
User-added image

I investigated further to see that I was getting an Internal Server Error.
User-added image

I have stripped functionality in the apex method the actionFunction calls until it does nothing. See Below:
 

public class UtilApplication {

    public List<List<SelectOption>> display {get;set;}
    public String assigned {get;set;}
    Map <String, Schema.SObjectType> objs {get;set;}
    
    public UtilApplication() {
        
        display = new List<List<SelectOption>>();
        
        objs = Schema.getGlobalDescribe();
        
        List<SelectOption> init_opts = new List<SelectOption>();
        
        // Value | Label
        init_opts.add(new SelectOption('Student_Application__c','Student Application'));
        init_opts.add(new SelectOption('Contact','Contact'));
        
        display.add(init_opts);
        
        System.debug('In constructor');

    }
    
    // method in question
    public void add_object() {
        System.debug('In here');
    }
}
The Visualforce looks like this:
 
<apex:page showHeader="false" sidebar="false" controller="UtilApplication">
    <head>
		<script>
        	function callJS() {
            	console.log("In this");
                select_section();   
            }
        </script>
    </head>  
    <body>
        <apex:form>
            <apex:outputPanel id="configure">
                <apex:outputPanel>
                    <apex:pageBlock title="Select Section">
                        <apex:actionFunction name="select_section" action="{!add_object}" reRender="configure"/>
                            <apex:selectList multiselect="false" value="{!assigned}" size="1" onchange="callJS()">
                                <apex:selectOptions value="{!display[0]}"/>
                            </apex:selectList>
                    </apex:pageBlock>
                </apex:outputPanel>
            </apex:outputPanel>
        </apex:form>
    </body>
</apex:page>

I have used actionFunctions like this before so I am not sure what the issue is.

Any input would be great.

Thanks!

 

Hi,
I am trying to insert data into obj2 based on some condition in obj1 through handler /apex class but it is not working.
Please find the code
trigger orderAccountTransactionUpdate on Account (before update) {

 Order__c  orderAccount = new Order__c();

 system.debug('inside trigger');

orderAccount.lstNewAccounts = Trigger.new;
orderAccount.lstOldAccounts = Trigger.old;

// Trigger Logic – Before Update

    if((Trigger.isAfter && Trigger.isUpdate) ) {
 
  orderAccount.check(Trigger.new, Trigger.oldMap);

    }
    
  }
  
  
  public class OrderAccountTransaction {

    public List<Account> lstNewAccounts = new List<Account>();
    public List<Account> lstOldAccounts = new List<Account>();
    
    public void check(List<Account> Accounts, Map<Id, Account> oldAccount) {
  
    Map<Id, Account> mapVerifyOldAccounts = new Map<Id, Account>();
    List<Order__c> createOrder = new List <Order__c> ();
    
       for(Account acc : Accounts){
			system.debug('Accounts' + Accounts);
			system.debug('oldAccount' + oldAccount);
          Account beforeUpdate = oldAccount.get(acc.Id);
		   
          if(acc.Email!=beforeUpdate.Email) {
		  
		  NOT GOING INSIDE THIS
          
          system.debug('inside if');
              createOrder.add(new Order__c (Action__c  = 'insert',Status__c  = 'success'));
            }                             
    }
    try {
        insert createOrder;
    }
    catch (Exception Ex){
        system.debug(Ex);
    }


}

}



 
Hello!

Task: I am trying to create pretty much simple visualforce page. Table with 5 columns. Column 1 = Employee name. Column 2-5 = Employee completed courses.

Problem: Faced a problem creating columns for employee courses. These columns should output the TRUE or FALSE value e.g. if employee has completed a course or not. The current implementation looks like:
     
<apex:page standardController="CourseEnrollment__c" recordSetVar="records" id="thePage" cache="false"> 
<apex:form id="theForm"> 
    <apex:pageBlock id="thePageBlock"> 
        <apex:pageBlockTable value="{!records}" var="record" id="thePageBlockTable"> 
            <apex:column >
                <apex:outputField value="{!record.Employee__r.Name}" id="EmployeeNameDOM" /> 
                <apex:facet name="header">Name</apex:facet>
            </apex:column>
            <apex:column>
                <apex:outputText value="{!IF(!record.Course__r.Status == 'Completed','Completed','Expected')}" id="CourseNameDOM" /> 
                <apex:facet name="header">Course status</apex:facet>
            </apex:column>
        </apex:pageBlockTable> 
    </apex:pageBlock> 
</apex:form>
</apex:page>
The main object is CourseEnrollment, Employee and Course are related objects (master-details relation -> http://www.screencast.com/t/nLStStlAjzr)
Code above is just a test, trying to make IF statement work - no luck (also tried to use CONTAINS).

Question:
What is the right way to compare custom objects values on visualforce page? Is it worth to use custom controller, and get all required data already inside the custom class, not to complicate visualforce page structure?

 
Here is my full error message:
CANNOT_INSERT_UPDATE_ACTIVATE_ENTITY: T_TSC_Seek_Vehicle_Obj: execution of BeforeInsert
 
caused by: System.QueryException: Non-selective query against large object type (more than 100000 rows). Consider an indexed filter or contact salesforce.com about custom indexing.
Even if a field is indexed a filter might still not be selective when:
1. The filter value includes null (for instance binding with a list that contains null)
2. Data skew exists whereby the number of matching rows is very large (for instance, filtering for a particular foreign key value that occurs many times)
 
Trigger.T_TSC_Seek_Vehicle_Obj: line 41, column 1
 
trigger T_TSC_Seek_Vehicle_Obj on Technical_Service_Campaign__c (before insert, before update) {

	//	list of Model, Chassis Number, Service Records
	//Set<String> tscModel		= new Set<String>();
	Set<String> tscChassis		= new Set<String>();
	Set<String> tscBrRepOrd		= new Set<String>();
	
	for (Technical_Service_Campaign__c tsc: Trigger.new) {
		//tscModel.add(tsc.Recall_Model_Code__c);
		tscChassis.add(tsc.Recall_Chassis__c);
		tscBrRepOrd.add(tsc.Recall_Branch_Code__c + tsc.Recall_Repair_Order__c);
	}

	//  TSC Recall Chassis => SFDC Vehicle Id, SFDC Product Id
	Map<String, Id> mapVehicle = new Map<String, Id>();
	Map<String, Id> mapProduct = new Map<String, Id>();
	Vehicle__c[] vs = [Select Id, EDMS_Chassis_Number__c, Product__r.Id
					   From Vehicle__c
					   Where EDMS_Chassis_Number__c In :tscChassis
					   Limit 200];
	for (Vehicle__c v: vs) {
		//	gather Vehicle Id, Model Id
		mapVehicle.put(v.EDMS_Chassis_Number__c, v.Id);
		mapProduct.put(v.EDMS_Chassis_Number__c, v.Product__r.Id);
	}

	//	TSC Recall Repair Order, Branch Code => SFDC Service Records
	Map<String, Id> mapSvcRec = new Map<String, Id>();
	Service_Record__c[] srs = [Select Id, Branch_Repair_Order__c
							   From Service_Record__c
							   Where Branch_Repair_Order__c In :tscBrRepOrd
							   Limit 200];

	for (Service_Record__c sr: srs) {
		system.debug('T_TSC_Seek_Vehicle_Obj: SR matched: ' + sr);
		mapSvcRec.put(sr.Branch_Repair_Order__c, sr.Id);
	}

	//	Update Technical Service Campaign object based on external Id	
	for (Technical_Service_Campaign__c tsc: Trigger.new) {
		if (mapVehicle.containsKey(tsc.Recall_Chassis__c)) {
			tsc.Vehicle__c = mapVehicle.get(tsc.Recall_Chassis__c);
			tsc.Model__c = mapProduct.get(tsc.Recall_Chassis__c);
		}

		if (mapSvcRec.containsKey(tsc.Recall_Branch_Code__c + 
								  tsc.Recall_Repair_Order__c)) {
			tsc.Service_Record__c = mapSvcRec.get(tsc.Recall_Branch_Code__c + 
								  				  tsc.Recall_Repair_Order__c);
		}
	}
}
This trigger runs fine in Sandbox. Problem occurs when new records are being Upsert in Production. Did a lot of searches, but most problems were related to Opportunity object. Mine is a Custom Object.

I have similar Trigger for other Custom Objects, which worked fine previously, until the recent update by SFDC (Fall 2015? I don't live in 4 seasons country.). Things start crumbling 1 by 1. I had to remark this whole piece of code in order for data to be loaded into Production. With that being said, the new records would have empty Lookup field, which should reference to respective Vehicles.

Records are upserted via batch job of 50 records.

Thank for your time.
Hi all,

looking for Apex syntax how to open a VisualForce page
ie :
 if (field==Case1)
{open visualForce1}
 if (field==Case2)
{open visualForce2}

Many thaks for your assistance.
Dear Friends,

I am facing some newbie jerks while trying to call a controller froma  VF Page.

This is the error which I tried to debug a lot from Developer forums, but not of much help:

Error is: Formula Expression is required on the action attributes.

My VF Page:

<apex:page controller="BankDetailsController">
     <apex:form >
   <apex:pageBlock >
      <apex:commandButton value="BANK" action="{!getbankDet}"/>
         <apex:pageBlockSection>
             Following are the Bank Details
                   {!Response}    
       </apex:pageBlockSection>
  </apex:pageBlock>
  </apex:form>
</apex:page>

My Controller: calls a web service which I imported as a Apex class in my org <basically its a web service written in another salesforce org of mine>

public class BankDetailsController {
    
    //public string bank { get { return getbankDet(); } }
    public String Response {get; set;}
    public string getbankDet() 
    {

        string accname = 'GoGlobalStrategies';
        partnerSoapSforceCom.Soap myPartnerSoap = new partnerSoapSforceCom.Soap(); 
        partnerSoapSforceCom.LoginResult partnerLoginResult = myPartnerSoap.login('somnath.paul4@cognizant.com', 'MyPasswordgPeEzXp6zqiICng3M8wKQtqd');
        soapSforceComSchemasClassGetbankdet.SessionHeader_element webserviceSessionHeader=new soapSforceComSchemasClassGetbankdet.SessionHeader_element();
        webserviceSessionHeader.sessionId = partnerLoginResult.sessionId;
        soapSforceComSchemasClassGetbankdet.GetBankDetailsofAccount getBankdet=new soapSforceComSchemasClassGetbankdet.GetBankDetailsofAccount();
        getBankdet.SessionHeader=webserviceSessionHeader;
        Response = getBankdet.getBankDetails(accname);
        return Response;
 }
}

When I click on the BANK button in my VF Page, the response should flow in, but actually the error flows out :(

Can anyone tell me where am I going wrong here?
 
How to open a tab in a same window using javascript
Hi folks,

I have a requirement like,I have a command button and if any one is clicking on this,we are redirceting to another page but when ever the user is closing the same tab or browser,we are throwing an error message through JavaScript(window.onbeforeunload event) but here the problem is,if am clicking on the command button  this script is executing i.e, this error message is coming and i want to stop script execution on clicking on command button.

Please help me out!!!!!

Hello,

          I have a dateTime picker used in the tags as follows:

<apex:input label="End Date: " type="datetime-local" value="{!endDate}"/>

Users in my organization want to have it displayed as DD/MM/YYYY, since, the picker displays date as MM/DD/YYYY. 

Could you, please, help me in solving this issue?

I thank you.

Regards,
Vijay Birsingh.

hello friends,
How to use apex dataloader for multiple SF developer account.as i have two SF developer account and i can log-in using one account but now when i use dataloader for second account its not providing me security code to log-in.
 how to log-in on dataloader for second account.
please help
I have below code to redirect to diffrent page based on user's region, region is a custom field picklist:

{!REQUIRESCRIPT("/soap/ajax/29.0/connection.js")} 
{!REQUIRESCRIPT('/soap/ajax/29.0/apex.js')} 
var x = {!TEXT($User.Region__c)}; 
if(x == 'India'){ 
window.open("/apex/page1"); 

else{ 
window.open("/apex/page2"); 
}

But I am getting "India is not defined" error. Please help me out.

Thanks in advance