• ministe_2003
  • NEWBIE
  • 195 Points
  • Member since 2011

  • Chatter
    Feed
  • 7
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 27
    Questions
  • 77
    Replies

Hi Community 

 

I have an apex:commandButton that links to a JS function to open a new window.

The issue is that the link of the window that is referenced in the JS Function contains Global Variables, they do not merge as it is not VF Code. Can anybody suggest a solution?

 

My button:

 

<apex:commandButton value="MyButton" onclick="keyAccountData();return false;"/>

 

 

JS Function:

 

function keyAccountData() {
window.open('https://www.appextremes.com/apps/Conga/PointMerge.aspx?SessionId={!$Api.Session_ID}&ServerUrl={!$Api.Partner_Server_URL_250}&Id={!Account.Id}&DefaultPDF=1&DS7=3&LG4=1&LG3=2&OFN={!Account.Name}___OnePager_Onboard___{!NOW()}&TemplateId=a17Q0000001IguN&ReportId=00OQ0000000ThTh,00OQ0000000ThTX','Conga','height=175, width=300');
}

 

Or is it better to initialize the link in my controller?

 

Thanks!

  • November 21, 2013
  • Like
  • 0

sfdcfox helped me figure out how to get a list of accounts now I need to get a list of contacts from that list. I don't even have a code sample to kick this off because I can't figure out the best way to do it short of iterating through each account in the account list then building up a master list of its contacts. Does that sound like the approach to use or is there some kind of SOQL I can do against the accounts list I have?

Hi all, does anyone know whats going on here? I have a change set that im validating on production and it fails with the following:

 

API NameTypeLineColumnProblem

Contract_Recurring_Service__c.Billing_Period__cCustom Field Definition313Cannot change field type of a custom field referenced in Apex class or trigger: <a href="/01pD0000000GGve">ContractRecurringService</a>
Recurring_Service_Line_Item__c.Billing_Period__cCustom Field Definition313Cannot change field type of a custom field referenced in Apex class or trigger: <a href="/01pD0000000GGvf">Contract_Recurring_Invoice_Calculations</a>

 

 

Now its correct I am changing the field type from text to picklist, and it is referenced in both those classes in a soql statement both of and are in my change set also. Does anyone have any idea how to solve this as im stumped.

Hi,

I am getting an error and not able to able to figure out what the issue is. Please throw your ideas.

Below is the code:

1  public class testing
2  {
3   String strQ1Opt1='0-20 million';
4   List<SelectOption> lstSelOptQ1;
5  lstSelOptQ1 = new List<SelectOption>();
6  lstSelOptQ1.add(new SelectOption(strQ1Opt1,strQ1Opt1,false));
7  }

Error: Compile Error: unexpected token: '=' at line 5 column 16

-------------------------------------------------------------------------------------------------------------------------------------------

And when i change the code pasted as below, a different error is thrown.

Code:

1 public class testing

2 {

3  String strQ1Opt1='0-20 million';

4 List lstSelOptQ1 = new List();

5 lstSelOptQ1.add(new SelectOption(strQ1Opt1,strQ1Opt1,false));

6 }

Error:Compile Error: expecting a right parentheses, found 'new' at line 5 column 20

 

Please point out any issues in the above code.

 

Thanks.

Asif

  • May 04, 2012
  • Like
  • 0

how do i get salesforce to search custom fields on custom objects?

 

currently when i use the left hand tool bar search is shows no results on custom objects, even if i select the custom object from the drop down. i was under the impression salesforce automatically will handle this. So either there is an issue or there is a configuration setting i have to set. 

 

thanks

  • May 03, 2012
  • Like
  • 0
Hi all,
I'm trying to insert two new opportunities into the system in Apex based on user input.  The values will be identical on both, apart from the Close Date which will always be different.  However on the insert call, I'm getting the error in the subject.  Does anyone know why I'm getting this and how to get around it?  Why can I not insert more than one opportunity at once, regardless of the fact many of the fields are identical?  Here's the code I'm using to create the opportunity records, note that popOpp is an opportunity record created in Apex, and it's fields are populated in a visualforce page.  I then apply these values to new opportunityrecords and denamically populate the close date:

Date closeDate = fw.Start_Date__c;
for(integer i = 1; i <= numOpps; i++){
    opportunity opp = new Opportunity(
     Name = fw.Name+' - '+monthMap.get(closeDate.Month())+' '+closeDate.Year(),
     CloseDate = CloseDate,
     AccountId = popOpp.AccountId,
     StageName = 'R3 - Qualified Lead',
     Booking_Entity__c = popOpp.Booking_Entity__c,
     Order_to_place__c = popOpp.Order_to_place__c,
     Booking_Site__c = popOpp.Booking_Site__c,
     Budget_quote__c = popOpp.Budget_quote__c,
     Industry__c = popOpp.Industry__c,
     Received_Date__c = popOpp.Received_Date__c,
     End_User_Company_Name__c = popOpp.End_User_Company_Name__c,
     Quote_Required_By_Date__c = popOpp.Quote_Required_By_Date__c,
     Country__c = popOpp.Country__c,
     Date_Quoted__c = popOpp.Date_Quoted__c,
     Terms_Conditions__c = popOpp.Terms_Conditions__c,
     Quoted_Lead_Time__c = popOpp.Quoted_Lead_Time__c,
     CurrencyIsoCode = popOpp.CurrencyIsoCode,
     OwnerId = popOpp.OwnerId
    );
    oppList.add(opp);
    closeDate = closeDate.addMonths(selectedFreq);
   }
  }
...
Database.SaveResult[] oppSrList;
   try{
    oppSrList = Database.insert(oppList);   <--ERROR IS HERE
   }catch(Exception e){
    ApexPages.addMessages(e);
    return;
   }

Thanks
Hi all,
Since updating to summer 14 a lot of my tests are failing with the UNABLE_TO_LOCK_ROW error.  It's all coming from the same line of code, which is some global code to generate records for testing many different things, such as sample accounts, opportunities etc.  This is the section that's failing:

@IsTest(SeeAllData=true)
    public static void createTestPricebookEntry(){
    	if(pbeCreated == null){
				pbeCreated = false;
			}
			if(!pbeCreated){
    		pbeCreated = true;
	    	//stdPbId = Test.getStandardPricebookId(); activate once we update to summer 14
				stdPbId = [SELECT Id FROM Pricebook2 WHERE isStandard = true].Id; //deactivate once we update to summer 14
	    	Product2 p2 = new Product2(Name = 'Engineered - Spur', ProductCode = 'EO', isActive = true);
	    	insert p2;
	    	
	    	newProdId = p2.Id;
	    	
	    	PricebookEntry stdPbe = new PricebookEntry(Product2Id = newProdId, Pricebook2Id = stdPbId, unitprice = 50, useStandardPrice = false, isActive = true, CurrencyISOCode = 'GBP');

	    	insert stdPbe;       <-- THIS IS THE FAILING LINE
	    	pbeId = stdPbe.Id;
    	}
    }
This method can be called from many different places but is mostly called from another similar test class which creates a test opportunity with product lines.  It's causing 20 of my classes to fail which worked perfectly until the update to Summer 14.  Does anyone know why this is suddenly failing and what I can do to prevent it?  The class is a public but all my variables and methods are static, which I thought should prevent this problem.

Thanks
Hi,
I've signed up with postcode anywhere and have some script which gets the latitude and longitude of an address while it is being entered, and populates these values into custom number fields.  This works perfectly well on records which exist because I can populate the values with script by first querying the record from the database then entering the values.  Here's my code:

function (control, address) {
  var imported = document.createElement('script');
  imported.src = '/soap/ajax/30.0/connection.js';
  document.head.appendChild(imported);

  switch (control.salesforce.fields.Street) {
    case "acc17street": {
      var location = document.getElementById("acc17street").value + ", " +
      document.getElementById("acc17state").value + ", " +
      document.getElementById("acc17zip").value;
    break;
    }
    case "acc18street": {
      location = document.getElementById("acc18street").value + ", " +
      document.getElementById("acc18state").value + ", " +
      document.getElementById("acc18zip").value;
    break;
    }
    case "lea16street":{
      location = document.getElementById("lea16street").value + ", " +
      document.getElementById("lea16state").value + ", " +
      document.getElementById("lea16zip").value;
    break;
    }
  }

  pca.fetch("Geocoding/International/Geocode/v1.10", { Key: control.key, Location: location, Country: control.country },
    function (response) {
      debugger;

      var newRec;
      var recId;
      recId = window.location.href.substring( window.location.href.indexOf('.com/') + 5, window.location.href.indexOf('.com/') + 20 );

      switch (control.salesforce.fields.Street) {
        case "acc17street": {
          newRec = new sforce.SObject("Account");
          newRec.id = recId;
          newRec.Bill_To_Lat__c = response[0].Latitude;
          newRec.Bill_To_Long__c = response[0].Longitude;
        break;
        }
        case "acc18street": {
          newRec = new sforce.SObject("Account");
          newRec.id = recId;
          newRec.Ship_To_Lat__c = response[0].Latitude;
          newRec.Ship_To_Long__c = response[0].Longitude;
        break;
        }
        case "lea16street":{
          newRec = new sforce.SObject("Lead");
          newRec.id = recId;
          newRec.Lat__c = response[0].Latitude;
          newRec.Long__c = response[0].Longitude;
        break;
        }
      }

      var updResult = sforce.connection.update([newRec]);
    }
  );
}



The problem arrises when a user is creating a NEW record.  There is no record in the database for me to query so I don't know how I can populate the values.  Note that I do not wish to have the custom Lat__c and Long__c fields on the page layout (otherwise I could do this just by entering the values in the fields with javascript) and I cannot populate the values on the New event by url hacking, because I need the user to enter the address.

Does anyone know of a way I can populate fields on a record whilst it is being created?

Thanks

Hi,

If you have an element conditionally not rendered at load time, how can I attach a jQuery function to it?  I have a button which is hidden at load time but renders once all fields have been filled out.  I have attached a jQuery function to listen for the button click and perform an action, but it doesn't work.  I removed the rendered attribute from the button and magically, the jQuery worked!  So I know its not the code, its because the element isn't rendered and so presumably doesn't exist within the DOM when the page is loaded.

 

So my question - how can I get the function to work on a button which is not rendered at load time?

 

Thanks

I'm having trouble using the new html5 compliant apex:input field.  I'm working with maps and trying to set a number in the value part of the map, related to a corresponding Id key.  The map is called "prodQty" and an entry in the map might look like {XXXXXXXXXXXXXXXXXX,10} so the Key is an Id and the value is a number.

 

Here is a sample of what works using a normal input:text field:

 

<apex:inputText value="{!prodQty[p.Id]}" />

 All this does on the VF page is simply create an inputText field and display the corresponding number from the map.  I can change that number and it updates the map no problem.

 

I wanted to use the HTML5 number type and so set it up with this code:

 

<apex:input type="number" value="{!prodQty[p.Id]}" />

 Looks pretty standard to me, but I get this error:

 

Expected input type 'text', got 'number' for Id data type

 

It seems to be pulling through the key of the map rather than the value which is odd, because with a standard inputText component the value syntax works perfectly so why does the new component not recognise that I'm pulling through a number instead of an Id?  Is it impossible to use this new component with a map value?  It'll be an unfortunate limitation if that's the case!

 

Thanks for any advice.

I'm getting an odd error when trying to set a value in a map from a pageBlockTable.  Here's my Map:

 

prodList = *select some PricebookEntry records*

for(PricebookEntry pe : prodList){
  prodQty.put(pe, 0);
}

 

So I'm querying PricebookEntry records and then creating a map where the PBE is the key and an integer is the value.  This is so I can assign the number of rows of each PricebookEntry that I want.  This is the pageBlockTable I've written:

 

<apex:pageBlockTable value="{!prodQty}" var="p" columns="6">
  <apex:column headerValue="Quantity">
    <apex:inputText value="{!prodQty[p]}" />
  </apex:column>
  <apex:column headerValue="Product Name" value="{!p.Product2.Name}" />
  <apex:column headerValue="Product Code" value="{!p.Product2.ProductCode}" />
  <apex:column headerValue="Product Family" value="{!p.Product2.Family}" />
  <apex:column headerValue="Currency" value="{!p.CurrencyIsoCode}" />
  <apex:column headerValue="Requires Sub Group" value="{!p.Product2.Requires_Sub_Group__c}" />
</apex:pageBlockTable>

 Which displays the table nicely.  The first column is an input text field where I can enter the number of each row I want (They're all defaulted to zero, as per the Map initialisation code) and the rest of the columns display the specified PricebookEntry field.

 

The problem comes when the user tries to progress.  After entering the values they want, they press a "Select" Command Button and this returns errors like this:

 

Value '01uXXXXXXXXXXXXXXX' cannot be converted from core.apexpages.el.adapters.SObjectELAdapter to common.apex.runtime.SObjectRow 

Where the Id is a PricebookEntry Id - this error is repeated for every PricebookEntry that I display in the table.

 

The error is not related to the work I'm doing when the user clicks the Select - even if I call an empty method when the user clicks this button, this error still displays.  It's something to do with the inputText column in the table, ie

<apex:column headerValue="Quantity">
  <apex:inputText value="{!prodQty[p]}" />
</apex:column>

 I know this because the error doesn't display if I don't have this column in my table.

 

I'm sure I've done something like this in the past at a previous company but I can't get it working this time.  All I want to do is update the value assigned to the relevant PricebookEntry's row in the map so I know how many of each row to create.  I've never encountered this error before and it doesn't show up in debug logs so I'm stumped.  Does anyone know what I'm doing wrong?

 

Thanks

We have several validation rules on opportunities and opportunity product lines which come into force at different stages of an opportunity's life and users are regularly shown error messages, the likes of "you cant change the stage until you populate this field on all the product lines" so they are given errors when updating the opportunity because the change they're making triggers an error on the lines, and vice versa.

 

I'm just wondering if anyone has a nice solution to this other than constantly stopping users in their tracks?  Instead of the user just being stopped and having to manually go and change things, I'd like for salesforce to actually take them to the problem so they can fix it, and then have their original update performed.  All seamless with no horrible error messages and clicking here and there to get around.


In my mind, this is how it world work:

 

User tries to change stage to a value which causes validation rules to fire on the lines -> User is immediately taken to the first line page without any errors or clicking, and this page shows the field which they need to populate -> if there's any other lines, the user is looped through the pages so they can populate the values -> the user is taken back to the opportunity page and can see that their original change which triggered it all (the stage change) has been performed.

 

Is this possible?  Could it be achieved with flows or something like?  I'd love any feedback or suggestions.

Hi,

I've come across what appears to be a couple of system bugs when using Visualforce Charting in IE10.  There is already a known bug whereby clicking on a dataseries in the legend causes the colour series to be lost (see here https://success.salesforce.com/issues_view?id=a1p30000000Sv3SAAS) but my issue is much greater.

 

I have a chart which contains two bar charts and a line chart, all within one chart.  In IE10:

 

BUG 1

when a user clicks on a bar dataseries in the legend, that bar series is correctly removed from the chart, at this point (apart from the colour bug) everything is fine.  However, clicking on it again to make it reappear causes a problem - when the chart is re-drawn, the second bar series is redrawn in a completely opaque colour instead of being correctly filled.

 

BUG 2

Worse still, clicking on both bar series in order to hide them both and only display the line, causes them to be removed completely!  Clicking either series to make them reappear does not add them back into the chart.  Strangely, the data is still there in the background because when you hover the mouse over where the bars should be, the tooltips still appear, but the bars are not drawn at all.

 

I've sent a ticket in for this but the support person suggested I post this on here and hope that a salesforce developer see it (what a fantastic method of supporting your users!!)

 

I have some images which show these bugs in action and you can view them here: http://www.filedropper.com/visualforceie10chartingbugs

 

So here's hoping a dev sees this!

Hi all,

I'm trying to make a custom component out of a visualforce page I have because I've found another use for it, but with a different object.  Rather than re-write it all I figured I'd stick it into a component.  In this component I want to pass it a list of query results and display them in a table.  These results will be of different sobject types in my two different use cases, so I can't hard code the attribute type, so I'm passing sobject[] as the type, which seems to work.

 

Problem is I want to display data in the table columns and if I use this, I get an error:

 

<apex:attribute name="searchResults" type="SObject[]" required="true" description="which will store search results as a list of a type of SObjects"/>

<apex:dataTable id="resultsTable" value="{!searchResults}" var="sr">
 <apex:column headerValue="Search Results" width="100%">
  <apex:outputLabel id="nameLabel" value="{!sr.Name}" onclick="selectRecord('{!sr.Id}');"/>
 </apex:column>
</apex:dataTable>

 The error I get is:

Error: Unknown property 'SObject.Name'

 

Which relates to sr.Name.

 

I don't want to have to create a controller for this component if I can avoid it becuase I want to control its functionality from the controllers I will write for each of the two use cases I have right now, so is there a way I can display the data from a list I pass as a component?  The data does appear to be in there because if I just have value="test" in the output label, I get mulriple rows of the word "test", one for each of the results in the table, so the data must be in there somewhere - how do I get my component to display it?

 

Thanks

Hi all,

I've written a custom tab on which users can view their events but ever since the introduction of Shared Activities I've had a problem in that any event which has more than one contact assigned to it, does not appear in the query results.  I'm only querying the Event object, are shared activities stored under some different object?  I assumed they would still be Events but with related EventRelation objects storing the multiple contacts.

 

Note that strangely, the correct number of results are returned if I run the exact same query through the developer console but when run through the apex/VF I only get results containing a single contact.

 

Thanks

Steven

Hi all, got a weird issue.  I'm trying to test run some batch apex in my sandbox using the developer console to schedule immediate runs and I'm hitting a weird issue.

 

I'm trying to query a custom currency field caled Total_Won_This_Year__c but it's not being returned in my results.  I'm on the standard System Administrator profile so I should have no access problems with regard to field level security (which is set to editable anyway), the query runs and doesn't error out but when I try to access the field I get null exceptions and when I look in the debug logs I see the field isn't in the results.  I'm on the Enterprise Edition.

 

atrb.query = 'SELECT Id, CurrencyIsoCode, Total_Won_This_Year__c FROM Account';
...
return Database.getQueryLocator(query);
...
DEBUG|query = (Account:{CurrencyIsoCode=EUR, Id=001e0000004pCLSAA2}

Anyone know why I'd be having this issue?  I need to query the field and update a value and I'm using a batch so I can run it monthy.

 

Thanks

Hi all,

I'm creating my own custom Lookup popup page and it's gone brilliantly, the only problem I have is that the results are going off the bottom of the page.  I've wrapped the table in a div and set overflow to auto but it's still not working unless I set a fixed height to the div which I don't want to do if possible - the standard lookup page doesn't seem to since the results table always stretches to the bottom of the screen and a large results set causes a scroll bar to appear.  I want the same functionality.  Here's the code and style:

 

<style>
	.dTable{
		border: 1px solid #E0E3E5;
		line-height:130%;
		-webkit-border-radius: 5px;
		-moz-border-radius: 5px;
		border-radius: 5px;
		width:100%;
		overflow:auto;
	}
</style>


<div id="results" style="width: 100%; height:100%; overflow:auto; display:block;">
  &#60;&nbsp;&nbsp;
  <apex:outputLabel id="clearLabel" value="Clear Search Results" onclick="clearResultDiv();"/>
  <br />
  <apex:outputLabel styleClass="h2" value="Search Results" rendered="{!hasResults}"/>
  <apex:outputLabel styleClass="h2" value="All Application Engineers" rendered="{!NOT(hasResults)}"/>
  <apex:dataTable id="resultsTable" value="{!searchedAppEngs}" var="u" styleClass="dTable" headerClass="tHeader" columnClasses="tCol">
    <apex:column headerValue="Application Engineer (Sorted by surname)" width="100%">
      <apex:outputLabel id="nameLabel" value="{!u.Name}" onclick="selectUser('{!u.Id}');"/>
    </apex:column>
  </apex:dataTable>
</div>

 

Anyone want to be my CSS hero?!  Thanks in advance!

I'm trying to get some control of record creation which has been a little too global previously and I've noticed a problem whereby users who only have read only access to an accounts and its opportunities can still create an opportunity on that account.  Once created they cannot edit it in any way so this seems like a bug to me.  The Sharing button on the account clearly says Read Only and the user does not have any special privileges like Modify All Data or anything like that, so why can he still create an opp?  It seems like an oversight in the security of the org and I fear that I'll not be able to control it.  FYI Opportunity OWS are set to Private.

 

Thanks

Hi,

I'm trying to get ideas activated in my org and I'm having some trouble with the tab.  When I click the ideas tab I'm taken to a simple list view with the URL /087.  According to the documentation there should be a Tab button on this page which takes me to the fancy page at /ideas/ideaList.apexp but there isn't.  The only way I can get to that page is to type it into the address bar manually.  I want the tab view to be the default for all users.

 

If someone can add some clarity here I'd much appreciate it!

Hi all,

Is it possible to create an entry in the Approval History related list of an object without actually submitting it for approval?  I'm running an approval process through Apex but in some circumstances I'll know before submitting it that it doesn't require approval and so I do the Final Approval actions manaully in apex code and dont actually submit it for approval, however I'd also like to be able to create an entry in the Approval History section which states that it did not require approval.

 

Currently I'm using the Status field to display the fact it didn't reqire approval, but if possible I'd like the related list entry too.  I know you can create an approval process and immediately approve it, and that works APART from the fact that the approver receives an email asking him to approve the record, which I don't want to happen in this case.

 

Thanks

Steven

Hi all,

I'm trying to write some reports which are line graphs with two lines - one for actual values and another for the cumulative totals.  When I started doing this my plan was to select the standard X and Y axis values as cumulative then use the Plot Additional Values part to show the actuals, but I can't do it because ticking the Cumulative box makes both sets of values cumulative.  Is there a way to do this in Salesforce?  Here's an eg:

 

 

 

Regards

Hi all,

I'm toying with the idea of writing an app for the exchange, really just for the sake of giving it a shot and learning something new.

My idea would involve mass updating records and so I'm wondering if the BULK API would be the best solution just in case some users have massive orgs.

This is where my confusion lies and my lack of knowledge on the subject shows.  Having not used the BULK API or written a webservice before I don't quite know how this would work - I assume there must be some way of writing something using the BULK API which could then be packaged as an App for the exchange, but the only way I know of coding with the BULK API is in some external program, perhaps using Java or C# etc, and that would not be possible to package (I assume!).

 

So I guess my question is, how can I use the BULK API to mass update records in a way which doesn't rely on an external application?  The reason I've mentioned web services is because I assume any solution would have to involve one in some way.

 

Hope my question makes sense!

Steven

Hi all,

I have written a java application which imports csv files containing records from various ERP systems and creates/updates them in salesforce.

to do this I simply create SObjects in code like so:

		    	  Opportunity o = new Opportunity();
		    	  o.setOwnerId(record.get(1));
		    	  o.setAccountId(record.get(5));
		    	  o.setName(record.get(7));
		    	  o.setCloseDate(Main.formatDate(record.get(8)));

 and then upsert the records, which is working very well.  FYI, record is an entry in a 2d array and get() simply retrieves a value from that entry, in the corresponding position to the column it was on the csv file.

 

However I wonder if its possible to do this outside of the code and map the fields in an external properties file.  My reason for this is if we want to start recording additional fields, or stop recording an existing one, it would require a code change.

 

Is it somehow possible for an unskilled user to be able to open up a file in notepad and manage this?  To be honest I'm failing to see how it could be possible really because presumably the value assignment to a field would have to be written in code as above, but is there some way?

 

Thanks

Hi all,

I'm running an export using the weekly export service (only I'm running it right now instead of scheduling) and just wondered if this includes records which are in the recycle bin?  If not, is it possible to include them somehow

 

Thanks

Hi,

wondering if anyone can clarify something.  Triggers obviously run on batches of records. If a trigger fires for "before insert, before update", and I perform an upsert on several records which includes some updates and inserts, are two instances of that trigger created - one containing the updates and another containing the inserts, or does one trigger fire which contains both the inserts and updates?

 

The reason I'm asking is because I want to perform some conditional actions based on .isInsert and .isUpdate and depending on which of these two ways a trigger really works, I'm going to have to iterate differently.

 

I'm assuming that two triggers are created.  I want to collate a list of IDs, but only if a record is being inserted.  I assume that trigger.isInsert says that every single record in this trigger instance is being inserted; but I just want to make sure that it's not record dependent, and that trigger.isInsert can not be different, per record, in a single trigger fire.

 

Thanks!

We have some triggers that fire when an opportunity is edited. We are planning to roll out Advanced Multi-Currency and are concerned that when we update the exchange rates, this might fire the trigger when we do not want it to. Does anyone know if this would make the trigger fire? And if so, do you have advice on how to prevent that?
Hi all,
I'm trying to insert two new opportunities into the system in Apex based on user input.  The values will be identical on both, apart from the Close Date which will always be different.  However on the insert call, I'm getting the error in the subject.  Does anyone know why I'm getting this and how to get around it?  Why can I not insert more than one opportunity at once, regardless of the fact many of the fields are identical?  Here's the code I'm using to create the opportunity records, note that popOpp is an opportunity record created in Apex, and it's fields are populated in a visualforce page.  I then apply these values to new opportunityrecords and denamically populate the close date:

Date closeDate = fw.Start_Date__c;
for(integer i = 1; i <= numOpps; i++){
    opportunity opp = new Opportunity(
     Name = fw.Name+' - '+monthMap.get(closeDate.Month())+' '+closeDate.Year(),
     CloseDate = CloseDate,
     AccountId = popOpp.AccountId,
     StageName = 'R3 - Qualified Lead',
     Booking_Entity__c = popOpp.Booking_Entity__c,
     Order_to_place__c = popOpp.Order_to_place__c,
     Booking_Site__c = popOpp.Booking_Site__c,
     Budget_quote__c = popOpp.Budget_quote__c,
     Industry__c = popOpp.Industry__c,
     Received_Date__c = popOpp.Received_Date__c,
     End_User_Company_Name__c = popOpp.End_User_Company_Name__c,
     Quote_Required_By_Date__c = popOpp.Quote_Required_By_Date__c,
     Country__c = popOpp.Country__c,
     Date_Quoted__c = popOpp.Date_Quoted__c,
     Terms_Conditions__c = popOpp.Terms_Conditions__c,
     Quoted_Lead_Time__c = popOpp.Quoted_Lead_Time__c,
     CurrencyIsoCode = popOpp.CurrencyIsoCode,
     OwnerId = popOpp.OwnerId
    );
    oppList.add(opp);
    closeDate = closeDate.addMonths(selectedFreq);
   }
  }
...
Database.SaveResult[] oppSrList;
   try{
    oppSrList = Database.insert(oppList);   <--ERROR IS HERE
   }catch(Exception e){
    ApexPages.addMessages(e);
    return;
   }

Thanks
Hi all,
Since updating to summer 14 a lot of my tests are failing with the UNABLE_TO_LOCK_ROW error.  It's all coming from the same line of code, which is some global code to generate records for testing many different things, such as sample accounts, opportunities etc.  This is the section that's failing:

@IsTest(SeeAllData=true)
    public static void createTestPricebookEntry(){
    	if(pbeCreated == null){
				pbeCreated = false;
			}
			if(!pbeCreated){
    		pbeCreated = true;
	    	//stdPbId = Test.getStandardPricebookId(); activate once we update to summer 14
				stdPbId = [SELECT Id FROM Pricebook2 WHERE isStandard = true].Id; //deactivate once we update to summer 14
	    	Product2 p2 = new Product2(Name = 'Engineered - Spur', ProductCode = 'EO', isActive = true);
	    	insert p2;
	    	
	    	newProdId = p2.Id;
	    	
	    	PricebookEntry stdPbe = new PricebookEntry(Product2Id = newProdId, Pricebook2Id = stdPbId, unitprice = 50, useStandardPrice = false, isActive = true, CurrencyISOCode = 'GBP');

	    	insert stdPbe;       <-- THIS IS THE FAILING LINE
	    	pbeId = stdPbe.Id;
    	}
    }
This method can be called from many different places but is mostly called from another similar test class which creates a test opportunity with product lines.  It's causing 20 of my classes to fail which worked perfectly until the update to Summer 14.  Does anyone know why this is suddenly failing and what I can do to prevent it?  The class is a public but all my variables and methods are static, which I thought should prevent this problem.

Thanks
Hi,
I've signed up with postcode anywhere and have some script which gets the latitude and longitude of an address while it is being entered, and populates these values into custom number fields.  This works perfectly well on records which exist because I can populate the values with script by first querying the record from the database then entering the values.  Here's my code:

function (control, address) {
  var imported = document.createElement('script');
  imported.src = '/soap/ajax/30.0/connection.js';
  document.head.appendChild(imported);

  switch (control.salesforce.fields.Street) {
    case "acc17street": {
      var location = document.getElementById("acc17street").value + ", " +
      document.getElementById("acc17state").value + ", " +
      document.getElementById("acc17zip").value;
    break;
    }
    case "acc18street": {
      location = document.getElementById("acc18street").value + ", " +
      document.getElementById("acc18state").value + ", " +
      document.getElementById("acc18zip").value;
    break;
    }
    case "lea16street":{
      location = document.getElementById("lea16street").value + ", " +
      document.getElementById("lea16state").value + ", " +
      document.getElementById("lea16zip").value;
    break;
    }
  }

  pca.fetch("Geocoding/International/Geocode/v1.10", { Key: control.key, Location: location, Country: control.country },
    function (response) {
      debugger;

      var newRec;
      var recId;
      recId = window.location.href.substring( window.location.href.indexOf('.com/') + 5, window.location.href.indexOf('.com/') + 20 );

      switch (control.salesforce.fields.Street) {
        case "acc17street": {
          newRec = new sforce.SObject("Account");
          newRec.id = recId;
          newRec.Bill_To_Lat__c = response[0].Latitude;
          newRec.Bill_To_Long__c = response[0].Longitude;
        break;
        }
        case "acc18street": {
          newRec = new sforce.SObject("Account");
          newRec.id = recId;
          newRec.Ship_To_Lat__c = response[0].Latitude;
          newRec.Ship_To_Long__c = response[0].Longitude;
        break;
        }
        case "lea16street":{
          newRec = new sforce.SObject("Lead");
          newRec.id = recId;
          newRec.Lat__c = response[0].Latitude;
          newRec.Long__c = response[0].Longitude;
        break;
        }
      }

      var updResult = sforce.connection.update([newRec]);
    }
  );
}



The problem arrises when a user is creating a NEW record.  There is no record in the database for me to query so I don't know how I can populate the values.  Note that I do not wish to have the custom Lat__c and Long__c fields on the page layout (otherwise I could do this just by entering the values in the fields with javascript) and I cannot populate the values on the New event by url hacking, because I need the user to enter the address.

Does anyone know of a way I can populate fields on a record whilst it is being created?

Thanks
I met an error when I cloning an opportunity from a exist opportunity, the error says:

  common.exception.SfdcSqlException: ORA-20067: OPPORTUNITY_LINEITEM.PRICEBOOK_ENTRY_ID ORA-06512: at "BASHFUL.SOPPLINEITEM", line 696 ORA-06512: at line 1{call sOppLineItem.insert_opplineitems(?,?,?,?,?,...)} {call sOppLineItem.isert_opplineitems(?,?,?,?,...)}

 Who know that?

Hi Community 

 

I have an apex:commandButton that links to a JS function to open a new window.

The issue is that the link of the window that is referenced in the JS Function contains Global Variables, they do not merge as it is not VF Code. Can anybody suggest a solution?

 

My button:

 

<apex:commandButton value="MyButton" onclick="keyAccountData();return false;"/>

 

 

JS Function:

 

function keyAccountData() {
window.open('https://www.appextremes.com/apps/Conga/PointMerge.aspx?SessionId={!$Api.Session_ID}&ServerUrl={!$Api.Partner_Server_URL_250}&Id={!Account.Id}&DefaultPDF=1&DS7=3&LG4=1&LG3=2&OFN={!Account.Name}___OnePager_Onboard___{!NOW()}&TemplateId=a17Q0000001IguN&ReportId=00OQ0000000ThTh,00OQ0000000ThTX','Conga','height=175, width=300');
}

 

Or is it better to initialize the link in my controller?

 

Thanks!

  • November 21, 2013
  • Like
  • 0

Hi,

 

I want to call an apex method from outputilnk.

so, i tried using below code in VF page:

<apex:outputLink value="/{!p.Id}" onclick="CallApexMethod"> {!p.Name} </apex:outputLink>

 

 

<apex:actionFunction name="CallApexMethod" action="{!policy5}" onComplete="alert('After apex method') ;"/>

 

In class:

public PageReference policy5() {
       
        Update ListPolicy;
        return null;
    }

 

When I click on the output link , it should actually go to the record detail page.

So, with the above code when I click the link in the same browser Tab then it is working as expected like it is calling apex method and also redirecting to the record detail page.

 

but if I click on the link to open in new Tab, the above code is not working and its not executing my apex method.

 

IS there any other way to achieve the functionality i.e. both the ways (in the same tab as well in the new tab)?

 

 

  • November 21, 2013
  • Like
  • 0

Hi,

If you have an element conditionally not rendered at load time, how can I attach a jQuery function to it?  I have a button which is hidden at load time but renders once all fields have been filled out.  I have attached a jQuery function to listen for the button click and perform an action, but it doesn't work.  I removed the rendered attribute from the button and magically, the jQuery worked!  So I know its not the code, its because the element isn't rendered and so presumably doesn't exist within the DOM when the page is loaded.

 

So my question - how can I get the function to work on a button which is not rendered at load time?

 

Thanks

I'm having trouble using the new html5 compliant apex:input field.  I'm working with maps and trying to set a number in the value part of the map, related to a corresponding Id key.  The map is called "prodQty" and an entry in the map might look like {XXXXXXXXXXXXXXXXXX,10} so the Key is an Id and the value is a number.

 

Here is a sample of what works using a normal input:text field:

 

<apex:inputText value="{!prodQty[p.Id]}" />

 All this does on the VF page is simply create an inputText field and display the corresponding number from the map.  I can change that number and it updates the map no problem.

 

I wanted to use the HTML5 number type and so set it up with this code:

 

<apex:input type="number" value="{!prodQty[p.Id]}" />

 Looks pretty standard to me, but I get this error:

 

Expected input type 'text', got 'number' for Id data type

 

It seems to be pulling through the key of the map rather than the value which is odd, because with a standard inputText component the value syntax works perfectly so why does the new component not recognise that I'm pulling through a number instead of an Id?  Is it impossible to use this new component with a map value?  It'll be an unfortunate limitation if that's the case!

 

Thanks for any advice.

I'm getting an odd error when trying to set a value in a map from a pageBlockTable.  Here's my Map:

 

prodList = *select some PricebookEntry records*

for(PricebookEntry pe : prodList){
  prodQty.put(pe, 0);
}

 

So I'm querying PricebookEntry records and then creating a map where the PBE is the key and an integer is the value.  This is so I can assign the number of rows of each PricebookEntry that I want.  This is the pageBlockTable I've written:

 

<apex:pageBlockTable value="{!prodQty}" var="p" columns="6">
  <apex:column headerValue="Quantity">
    <apex:inputText value="{!prodQty[p]}" />
  </apex:column>
  <apex:column headerValue="Product Name" value="{!p.Product2.Name}" />
  <apex:column headerValue="Product Code" value="{!p.Product2.ProductCode}" />
  <apex:column headerValue="Product Family" value="{!p.Product2.Family}" />
  <apex:column headerValue="Currency" value="{!p.CurrencyIsoCode}" />
  <apex:column headerValue="Requires Sub Group" value="{!p.Product2.Requires_Sub_Group__c}" />
</apex:pageBlockTable>

 Which displays the table nicely.  The first column is an input text field where I can enter the number of each row I want (They're all defaulted to zero, as per the Map initialisation code) and the rest of the columns display the specified PricebookEntry field.

 

The problem comes when the user tries to progress.  After entering the values they want, they press a "Select" Command Button and this returns errors like this:

 

Value '01uXXXXXXXXXXXXXXX' cannot be converted from core.apexpages.el.adapters.SObjectELAdapter to common.apex.runtime.SObjectRow 

Where the Id is a PricebookEntry Id - this error is repeated for every PricebookEntry that I display in the table.

 

The error is not related to the work I'm doing when the user clicks the Select - even if I call an empty method when the user clicks this button, this error still displays.  It's something to do with the inputText column in the table, ie

<apex:column headerValue="Quantity">
  <apex:inputText value="{!prodQty[p]}" />
</apex:column>

 I know this because the error doesn't display if I don't have this column in my table.

 

I'm sure I've done something like this in the past at a previous company but I can't get it working this time.  All I want to do is update the value assigned to the relevant PricebookEntry's row in the map so I know how many of each row to create.  I've never encountered this error before and it doesn't show up in debug logs so I'm stumped.  Does anyone know what I'm doing wrong?

 

Thanks

Hi everybody,

 

I'm facing the following problem: my sandbox environment doesn' show up the code coverage column on Apex-Classes list after running all tests or just some particular Test Classes. And when I click Estimate your organization's code coverage it shows 0% of code coverage but there must be some code coverage. In fact I'm currently not able to evaluate the overall code coverage.

 

Can anyone give me a hint on what i'm missing or to look at?

 

Thanks in advance.

  • September 22, 2013
  • Like
  • 0