• GoodGroove
  • NEWBIE
  • 55 Points
  • Member since 2008

  • Chatter
    Feed
  • 2
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 3
    Questions
  • 26
    Replies

I am trying to use an Apex Class to dynanamically construct HTML in my company's web page.  The example below makes a good simplified example:

 

 

Apex Class:

public with sharing class web_controller_test {

 

  public String myString = '<a href="http://www.google.com/">Google</a>';

 

public String getNavString() {

return myString;
}

}

 

Force.com Page:

 

<apex:page controller="web_controller_test" standardStyleSheets="false" sidebar="false" showHeader="false" title="Test Page">

<apex:outputPanel id="subnav">
<apex:repeat value="{!NavString}" var="navstring">
{!navstring}
</apex:repeat>
</apex:outputPanel>

</apex:page>

 

The Apex Class has one function that is supposed to return a link to Google.  The SF Sites page calls that function, and the link is supposed to be brought into page code.

 

Except it doesn't.  Instead of returning HTML, it returns the incorrect safe-encoded version:

 

 

Output - What the code spits out:

<body>
&lt;a href="http://www.google.com/"&gt;Google&lt;/a&gt;
</body>

 

 

This is what it's supposed to look like:

 

 

What it should REALLY look like:

<body>
<a href="http://www.google.com/">Google</a>
</body>

 

Does anyone know how to display the actual string, and not the escaped version?

 

~ Nick

Hi,

 

we have 2 fields - SRQ_AGREED_TIME and SRQ_AGREED_TIME_OLD

for some purposes we need to save old value to SRQ_AGREED_TIME_OLD when SRQ_AGREED_TIME is changed.

 

 

i wrote trigger:

 

trigger SRq_agreed_time_save_old_value on Case (before update) {

  Case[] item_old = Trigger.old;

  Case[] item_new = Trigger.new;

 

  for ( Case item : item_new)

  {

    if (item_old[0].SRq_agreed_time__c != null)

    {

      item.SRq_agreed_time_old__c = item_old[0].SRq_agreed_time__c;

    }

  }

}

 

 

and test method: 

 

@isTest

private class Srq_agreed_time_tests {

 

  static testMethod void beforeUpdateCase() {

  test.starttest();

  Case[] cases = [Select id, SRq_agreed_time__c from Case where Case.Status != 'Closed'];

 

  for(Case item : cases)

  {

    item.SRq_agreed_time__c = DateTime.now();

    }

 

      test.stoptest();

    }

}

 

 

I don't know If I don't understand how to write test methods but I read article about writing more times.

Please help me or tell me som secrets :) how to edit it and successfuly deploy trigger to server??

 

thank you

 

  • September 29, 2009
  • Like
  • 0

Hi guys,

 

today I received a strange error message after trying to change the controller in the visualforce editor

 

Error: java.sql.SQLException: ORA-00001: unique constraint (CORE.AKAPEX_CLASS) violated ORA-06512: at "HAPPY.CAPEX", line 505 ORA-06512: at line 1 : {call cApex.update_class(?,?,?,?,?,?,?,?,?,?,?,?)})} 

 

 

and remebered about a Blog article on Wes's Blog about strange error messages where I found this

 

  

Error: java.sql.SQLException: ORA-00001: unique constraint (CORE.AKAPEX_CLASS) violated ORA-06512: at “SNEEZY.CAPEX”, line 505 ORA-06512: at line 1 : {call cApex.update_class(?,?,?,?,?,?,?,?,?,?,?,?)})} 

.

 

 

Looks like some SF guys are huge fans 'Snow White and the Seven Dwarfs' .

 

 

So the big question is, where are the others and of course where's Snow White?

 

 

 

Hi everybody,

 

maybe some one of you guys can help with this problem. I try to query all records from the WorkflowStep__c object where User = system.getUserInfo.getUserID() or the current user has an entry in the WorkflowResourceMember__c object

 

 

 

 

I tried the following query:

 

 

 

wsteplist = [

 

select

id,

Name

 

from WorkflowStep__c

 

where ShowInList__c = 'Open' AND

(User__c =: system.UserInfo.getUserId() OR

Ressource__c IN (select WorkflowResource__c from WorkflowResourceMember__c where Memeber__c =: system.UserInfo.getUserId() ) )

];

 

 but returned error: 

 

Error: Compile Error: Semi join sub-selects are only allowed at the top level WHERE expressions and not in nested WHERE expressions. at line 7 column 21 

 

I really appreciate your help

 

Cheers

Sebastian

 

 

Message Edited by GoodGroove on 07-03-2009 01:03 AM
Hi,

need help regariding my trigger below. Get this error code (SOQL does not contain results):

Severity and Description    Path    Resource    Location    Creation Time    Id
System.DmlException: Update failed. First exception on row 0 with id 00620000005uHyQAAU; first error: CANNOT_INSERT_UPDATE_ACTIVATE_ENTITY, simpleTrigger02: execution of AfterUpdate caused by: System.QueryException: List has no rows for assignment to SObject Trigger.simpleTrigger02: line 77, column 61    SFDC_Ph01_deploy_Renewal_Trigger/src/unpackaged/classes    simpleTrigger02testClass03.cls    line 138    1220262381688    2940

Question: Red marked code is causing error (below: Oli1). Why does APEX does not find my Opportunity ID? The log tells me that oppty1.id and oppty2.id is existing!
 
CODE:

trigger simpleTrigger02 on Opportunity (after update) {
    
    OpportunityLineItem oli1 =                         new OpportunityLineItem();
    OpportunityLineItem oli2 =                         new OpportunityLineItem();
    OpportunityLineItem oli3 =                         new OpportunityLineItem();
    OpportunityLineItem oli4 =                         new OpportunityLineItem();
    
    Opportunity oppty2 =                                  new Opportunity();
    Opportunity oppty3 =                                  new Opportunity();
    Opportunity oppty4 =                                  new Opportunity();
            
    List<OpportunityLineItem> oliList2 =         new List<OpportunityLineItem>();
     List<OpportunityLineItem> oliList3 =        new List<OpportunityLineItem>();
     List<OpportunityLineItem> oliList4 =        new List<OpportunityLineItem>();
     List<OpportunityLineItem> oliListX =        new List<OpportunityLineItem>();
     
     List<Opportunity> T_new =                      Trigger.new;
     ID oid1 =                                                    T_new.get(0).id;
     
     List<Opportunity> T_old =                        Trigger.old;
     ID oid2 =                                                    T_old.get(0).id;
          
    for (Opportunity oppty1 : Trigger.new){
                             
        if (oppty1.renew__c == true){
                                 
            for (Opportunity opptytest1 : Trigger.old) {
                                       
            Double cdate =                                                oppty1.RenewalTermCalcDouble__c;
            Integer i =                                                         cdate.intValue();
                            
            oppty2.accountid =                                                         oppty1.accountid;
            oppty2.CustomerOrderDate__c =                                 oppty1.CustomerOrderDate__c;
            oppty2.CustomerOrderedBy_del__c =                          oppty1.CustomerOrderedBy_del__c;
            oppty2.CustomerOrderID__c =                                      oppty1.CustomerOrderID__c;
            oppty2.CustomerOrderNumberAdditonal__c =              oppty1.CustomerOrderNumberAdditonal__c;
            oppty2.DateOfDelivery__c =                                             oppty1.DateOfDelivery__c;
            oppty2.Description =                                                         'Angelegt am: ' + dit.addhours(2);
            oppty2.GMDRetention__c =                                             oppty1.GMDRetention__c;
            oppty2.OpportunityInitial__c  =                                         oppty1.id;
            oppty2.InvoiceDate__c =                                                 oppty1.InvoiceDate__c;
            oppty2.name =                                                                    'Renewal 1.Jahr';
             oppty2.OwnerId =                                                             oppty1.OwnerId;
            oppty2.Pricebook2Id =                                                     oppty1.Pricebook2Id;
            oppty2.Probability =                                                         oppty1.Probability;
            oppty2.Product__c =                                                         oppty1.Product__c;
            oppty2.ProductOther__c =                                                 oppty1.ProductOther__c;
            oppty2.RecordTypeId =                                                     '012200000000ZErAAM';
            oppty2.Type =                                                                     'Renewal';
            oppty2.RenewalTerm__c =                                                 oppty1.RenewalTerm__c;
            oppty2.RenewalType__c =                                                    oppty1.RenewalType__c;
            oppty2.RequirementsDescription__c =                                 oppty1.RequirementsDescription__c;
            oppty2.StageName =                                                              'Renewal Open';
             oppty2.Service__c =                                                             oppty1.Service__c;              
            oppty2.CloseDate =                                                                 oppty1.CloseDate.addMonths(12);
         
             System.debug('DIE OPPTY1.ID:                     **********************' + oppty1.id);                          
            
            oli1.opportunityId =                             oppty1.id;
            oli1.quantity =                                 200.0;
             oli1.unitprice =                                 20.0;
             oli1.PricebookEntryId =                         '01u20000000fK10AAE';    
             
             oliListX.add(oli1);
            /*
            insert oliList2;
            */
            
            oli1 =                                             [Select quantity, unitprice, pricebookentryid, opportunityid from OpportunityLineItem where PricebookEntry.product2.ActivateRenewal__c =                                                                     TRUE AND PriceBookEntryID <> '01u20000000fK11AAE' AND OpportunityID = :oppty1.id limit 1];                                          
          insert oppty2;
                
          System.debug('OPPTY1.ID:                 **********************' + oppty1.id);                          
          System.debug(' OPPTY2.ID:                 **********************' + oppty2.id);                          
                            
                 oli2.opportunityId =                         oppty2.id;
                 oli2.quantity =                             oli1.quantity;
                 oli2.unitprice =                             oli1.unitprice;
                 oli2.pricebookentryid =                     oli1.pricebookentryid;
                 
                 oliList2.add(oli2);     
                         
                  insert oliList2;
                                 
            }
        }
        
    }
}

Hi,

 

I would like to be able to show a gif spinner on my visual force page as I am doing something on the background like loading data or waiting for data to come back before I update the page.

 

It will be ideal if I can replace apex:tags with a stylesheet that will be turned off or on based on user click.

 

 

Does anyone have a good solution for that I ma not very ajax savvy per say so any ideas will be appreciated.

 

 


Thank you. 

 

 

  • October 16, 2009
  • Like
  • 0

I am trying to use an Apex Class to dynanamically construct HTML in my company's web page.  The example below makes a good simplified example:

 

 

Apex Class:

public with sharing class web_controller_test {

 

  public String myString = '<a href="http://www.google.com/">Google</a>';

 

public String getNavString() {

return myString;
}

}

 

Force.com Page:

 

<apex:page controller="web_controller_test" standardStyleSheets="false" sidebar="false" showHeader="false" title="Test Page">

<apex:outputPanel id="subnav">
<apex:repeat value="{!NavString}" var="navstring">
{!navstring}
</apex:repeat>
</apex:outputPanel>

</apex:page>

 

The Apex Class has one function that is supposed to return a link to Google.  The SF Sites page calls that function, and the link is supposed to be brought into page code.

 

Except it doesn't.  Instead of returning HTML, it returns the incorrect safe-encoded version:

 

 

Output - What the code spits out:

<body>
&lt;a href="http://www.google.com/"&gt;Google&lt;/a&gt;
</body>

 

 

This is what it's supposed to look like:

 

 

What it should REALLY look like:

<body>
<a href="http://www.google.com/">Google</a>
</body>

 

Does anyone know how to display the actual string, and not the escaped version?

 

~ Nick

Hello,

 

I am looking into a way to create a Visualforce Email template to use for our Case auto-response.  What I'd like to be able to do is print a list of Suggested Solutions.

 

I know I can print the related list of Solutions with the code below.  However, I would like to print a list of Suggested Solutions, since when the case is opened, the Solutions will not be defined yet.

 

 

 

<messaging:emailTemplate subject="Your Case Has Been Opened" recipientType="Contact" relatedToType="Case"> <messaging:htmlEmailBody > (some unrelated html tabs / messaging) <table border="0" > <tr> <th>Solution Number</th> <th>Solution Name</th> </tr> <apex:repeat var="cx" value="{!relatedTo.CaseSolutions}"> <tr> <td><a href = "https://na1.salesforce.com/{!cx.SolutionId}">{!cx.Solution.SolutionNumber} </a></td> <td>{!cx.Solution.SolutionName}</td> </tr> </apex:repeat> </table> (some unrelated html tabs / messaging) </messaging:htmlEmailBody> </messaging:emailTemplate>

 

 

 

I have a commandbutton that opens a popup window but when the popup is launched the parent page seems to refresh. How can I prevent the parent page refresh from happening?

 

Any help much appreciated.

 

<script> var newWin=null; function openPopup() { var url="/apex/DocumentExt"; newWin=window.open(url, 'Popup','height=500,width=400,left=100,top=100,resizable=no,scrollbars=no,toolbar=no,status=no'); newWin.focus(); return false; } </script> <apex:commandButton onclick="openPopup();" value="Popup" immediate="true"/>

 


 

  • October 07, 2009
  • Like
  • 0

Ihave a need to group and sum a custom object related list and show it in a standard page layout on the account page.

 

Related list items are as follows:

 

Order Widget Name  Qty

1        ABX                 5

2        ABX                 2

3        WWW              3

5        WWW              3

9        ABC                 3

 

Need it to show on the account page as follows:

 

Widget Name          Sum Qty

ABX                              10

WWW                             6

 

I am by no means a programmer but dabble in Apex/Visualforce.

 

Thanks for any help.


Kevin

Hi,

 

Is there a way to get the actual object using the object name?

 

Thanks.

  • October 02, 2009
  • Like
  • 0

Hello,

 

When I cancel an operation on a Visualforce page, I would like to return to the calling page.

 

In my case, the Visualforce  page is invoked from a custom button placed on an object view.

 

Is it possible to get an object view URL? I tried, but I could not find a specific merge field to pass the current page URL as a parameter (retURL).

I am trying to deploy and get these errors. What is going on?

Any help is highly appreciated.

  

 

!SESSION 2009-10-02 09:09:17.515 ------------------------------

-----------------
eclipse.buildId=M20090211-1700
java.version=1.6.0_16
java.vendor=Sun Microsystems Inc.
BootLoader constants: OS=win32, ARCH=x86, WS=win32, NL=nl_NL
Command-line arguments:  -os win32 -ws win32 -arch x86

!ENTRY com.salesforce.ide.core 2 0 2009-10-02 09:09:22.921
!MESSAGE  WARN [2009-10-02 09:09:22,921] (ProxyManager.java:init:49) - No proxy bundle found - default proxy service will be initialized


!ENTRY com.salesforce.ide.core 2 0 2009-10-02 09:15:28.921
!MESSAGE  WARN [2009-10-02 09:15:28,921] (BasePackageService.java:waitForResult:146) - Deploy or retrieve operation to 'eu0-api.salesforce.com' failed: UNKNOWN_EXCEPTION: An error occurred on your page. (UNKNOWN_EXCEPTION)


!ENTRY com.salesforce.ide.core 2 0 2009-10-02 09:15:28.937
!MESSAGE  WARN [2009-10-02 09:15:28,921] (PackageDeployService.java:deployWork:328) - Unable to retrieve components: ServiceException: UNKNOWN_EXCEPTION: An error occurred on your page. (UNKNOWN_EXCEPTION)


!ENTRY com.salesforce.ide.core 4 0 2009-10-02 09:15:28.937
!MESSAGE ERROR [2009-10-02 09:15:28,937] (BuilderController.java:handleException:134) - Unable to perform save on all files.

!STACK 0
com.salesforce.ide.core.services.DeployException: com.salesforce.ide.core.services.ServiceException: UNKNOWN_EXCEPTION: An error occurred on your page. (UNKNOWN_EXCEPTION)
    at com.salesforce.ide.core.services.PackageDeployService.deployWork(PackageDeployService.java:329)
    at com.salesforce.ide.core.services.PackageDeployService.deploy(PackageDeployService.java:160)
some 50 more
Message Edited by smeeh on 10-02-2009 04:49 AM
  • October 02, 2009
  • Like
  • 0

I'm a newbie, so please be patient!

 

I wrote the following trigger to create a contract when an opportunity closes (not exactly the best use of the contract process, but that's another story)

 

The trigger is supposed to create a contract and tie the contract to the opportunity.  Works perfectly - except it creates 2 contracts.

 

Any ideas on how I can enforce a 1:1 between opportunities and contracts?

 

Any help is most appreciated!!

 

 

trigger UpdOpportunityOnStageChange on Opportunity (after update) {

List<Contract> contracts = new List<Contract>();

for (Opportunity a: Trigger.New) {

if (a.StageName == 'Contract Signed') {

contracts.add(new Contract(

CustomerSignedTitle = a.Type,

ContractTerm = 12,

Status = 'Draft',

Opportunity__c = a.Id,

AccountId = a.AccountId,

StartDate = System.today()));

}

}

insert contracts;

}

 

 

 

Hi All,

 

I have created a custom related list using pageblocktable. It is working fine. The issue which I am facing now is for some accounts the records in the related list are more than 200 and the page becomes very long. So is it possible to give the Show 5 more » and Go to list (50+) » (displayed in standard Related List by default) links in the pageblocktable.

 

Thanks 

AJ

Hey all!

 

Here's my scenario:

 

Our customers are at specific web sites.  When they report an issue, they can (and often do) report the issue as occuring on MORE than their own site.

 

Currently, cases are automatically associated to the account that the contact is associated to.  But we need to be able to do essentially 2 things:

 

1. I don't want to break the contact/account relationship, but I need a way to identify that the issue being reported is NOT necessarily being reported for that Account record.

 

2. I need to enable the ability to attribute the case to more than one account record at a time.  Parent/Child accounts is not enough, as often the issue could be reported on 2 of the say 15 sites that are child accounts to the parent.

 

What I think I need is a "Lookup Field/Multi-Select Picklist".

 

My vision for the field is that it would allow support agents here to select from a list of values, populated from a custom field we created in every account recor.  They would need to be able to select 1 or more values in this field.

 

Thanks in advance for any help!

Hello everyone!!

 

I have a VF Page with this code:

 

 <apex:column headervalue="IDS"><a href="/servlet/servlet.FileDownload?file={!item.Attachment_Id__c});" target="_blank">{!item.Attachment_Name__c}</a></apex:column>                   
 

 

With this I open a PDF attached. Now I want, by doing clic, print this PDF, I've tried this

 

 

<apex:column headervalue="IDS"><a href="javascript:window.print(/servlet/servlet.FileDownload?file={!item.Attachment_Id__c});" target="_blank">{!item.Attachment_Name__c}</a></apex:column>                   
 

 

but it doesn't work!

 

any idea?

 

Thanks in advance!!!

hi all,

 

i need to update a hidden field using Apex code.

Is that possible. If so please provide some inputs regarding it.

 

Thanks in advance,

Bharath

Hi,

 

The pdf version of my VF page shows all input fields incorrectly; e.g. the dropdowns show up as a list of all available choices as opposed to showing only the selected guy, input text fields show up as nothing. Also the buttons don't show properly. Anybody knows of a fix to that?

 

Thanks.

Message Edited by asadim on 09-29-2009 12:32 PM
  • September 29, 2009
  • Like
  • 0

HI,

I'm trying to create a custom edit page using Apex class to retrieve the fields information and then display

the fields in vForce page. However I got the following error message in the process. Any help would be

appreciated. It's very helpful with some custom edit page sample codes. Thanks

 

Paul

 

System.NullPointerException: Attempt to de-reference a null object

 

 

 

 

 


  • September 29, 2009
  • Like
  • 0

Hi,

 

we have 2 fields - SRQ_AGREED_TIME and SRQ_AGREED_TIME_OLD

for some purposes we need to save old value to SRQ_AGREED_TIME_OLD when SRQ_AGREED_TIME is changed.

 

 

i wrote trigger:

 

trigger SRq_agreed_time_save_old_value on Case (before update) {

  Case[] item_old = Trigger.old;

  Case[] item_new = Trigger.new;

 

  for ( Case item : item_new)

  {

    if (item_old[0].SRq_agreed_time__c != null)

    {

      item.SRq_agreed_time_old__c = item_old[0].SRq_agreed_time__c;

    }

  }

}

 

 

and test method: 

 

@isTest

private class Srq_agreed_time_tests {

 

  static testMethod void beforeUpdateCase() {

  test.starttest();

  Case[] cases = [Select id, SRq_agreed_time__c from Case where Case.Status != 'Closed'];

 

  for(Case item : cases)

  {

    item.SRq_agreed_time__c = DateTime.now();

    }

 

      test.stoptest();

    }

}

 

 

I don't know If I don't understand how to write test methods but I read article about writing more times.

Please help me or tell me som secrets :) how to edit it and successfuly deploy trigger to server??

 

thank you

 

  • September 29, 2009
  • Like
  • 0

Has anyone developed an export to pull a data dictionary that contains the Salesforce Field Label and corresponding APEX Field Name for all standard and custom objects in an org. 

 

Or, if you already have in excel/CSV format with standard APEX Field Names and Field Labels, that would be great.

 

I've tried the APEX Data Loader 17 and APEX Explorer 8.0 to no avail--they only show the APEX Field Names.

 

Thus far, the best way to do is to run Data Loader Exports and Report Exports for each object and match the two extracts together in one spreadsheet.  (Very manual process.)

 

The other way is to go into each individual field to view the information. (Even more manual and tedious.)

 

There is an IdeaExchange example of this:  http://ideas.salesforce.com/article/show/64543

 

Message Edited by ScoutP on 09-28-2009 01:49 PM
Message Edited by ScoutP on 09-28-2009 02:18 PM
  • September 28, 2009
  • Like
  • 0

Hi can anyone please help me with this as i have posted it several times with no responce, it is really bugging me as i am so close and i am sure it is something really simple.

I have this code that creates a clone of an opportunity, it is a java script button on the opportuntiy page layout

 

// Copyright 2008 BrightGen Ltd - All Rights Reserved try{ {!REQUIRESCRIPT("/soap/ajax/14.0/connection.js")} // ** EDIT THIS QUERY TO LIST THE FIELDS YOU WANT TO COPY ** var result = sforce.connection.query("Select o.Type, o.StageName, o.Description, o.Amount, o.AccountId From Opportunity o WHERE o.Id = '{!Opportunity.Id}'"); var newOpp = result.getArray("records"); // Reset the Opp Id and reset fields to default values newOpp[0].Id = ''; newOpp[0].Name = "Renewal - {!Opportunity.Name}"; // ** EDIT THESE FIELDS TO SET DEFAULT ANY VALUES ** newOpp[0].StageName = "Prospecting"; newOpp[0].CloseDate = new Date(2099, 0, 1); newOpp[0].Type = "Renewal" var saveResult = sforce.connection.create(newOpp); if (saveResult[0].getBoolean("success")) { newOpp[0].id = saveResult[0].id; alert("Renewal Opportunity Has Been Created."); } else { alert("Failed to create clone: " + saveResult[0]); } // Refresh the page to display the new oppportunity window.location = newOpp[0].id; } catch (err) { alert (err.description ); }

 

but the problem i am having is that this only works when a date is manually imput into the code.

what i want it to do is clone the opportuntiy but for 1 year later.

i think the following line needs to be changed:

 

newOpp[0].StageName = "Prospecting";
newOpp[0].CloseDate = new Date(2099, 0, 1);
newOpp[0].Type = "Renewal"

 

But whatever i put i cannot get it to work

 

Can anyone please help me on this as i am so close to getting a prefect renewal button.

 

Thanks very much to anyone that can help me

 

 

Jake Maskell

Message Edited by jmaskell123 on 09-04-2009 08:13 AM