• prageeth
  • SMARTIE
  • 1525 Points
  • Member since 2008

  • Chatter
    Feed
  • 59
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 14
    Questions
  • 245
    Replies

Hi Guys,

 

I have a datalist which lists records based on certain criteria and with each record I include a button too. I have the button coded to show or hide an OutputPanel relative to it's row in the datalist. The problem is that I can't seem to get the button to perform the task for a single item in the datalist. It will only show or hide every OutputPanel in the list.

 

I've tried playing with the var attribute but haven't found anything that works.

 

Hope you can help.

 

Regards,

 

Paul

 

 

I have a text field that i want to trim and have been trying with substring:

 

 

Field_Name__c.substring(5,27);

 However i get errors

System.StringException: Ending position out of bounds: 28

 When the field is less than 32 characters. It works fine if i say (5,10) as all have at least 15 characters.

 

 

 

Any tips on how i can trim this to ignore the first 5 characters and then return no more than 27 after that.

 

 

  • October 21, 2010
  • Like
  • 0

Hi,

 

how to get date selector beside a field of type date in vf page.

 

 

for example:

fromDate

 

it could be possible with <apex:inputfield/>(it will come automatically) but i am not using the same standard controller in the page.

 

here the fromdate field's object is different from the object mentioned in the standardcontroller.

 

 

Hi,

I have a custom button that sends order information to another system.  The button's content Source is a visualforce Page.  The visualforce page's controller does the transfer of data by calling a webservice.  The vpage then displays the response of the webservice.

 

The problem we are running into is the users are double clicking the button.

 

I figured I would disable the button after the first click, but I cannot figure out how to do that.  I need the button disabled as soon as the user clicks the button.  I can't disable it on the visual force page because to much time has elapsed before the disable will take place. I thought I would try disabling it in the controller but I don't know how to do that.

 

Can anyone help?

I have run into this problem in a few places with Contract. It's pretty obvious that Contract has an Id, as it is visible in the URL for the individual contract.

 

I am creating a custom button and I need to use the Id to load up the correct Contract in my visualforce page. The page works fine if I manually paste in the Id. The button is set to "URL" as the content source, and the following code is used: 

 

 

apex/PDAdContract?id={!Contract.Id}

So, why would it say that Contract has no Id? How can I get the Id?

 

THanks! 

 

Hi,

 

I'm trying to put an apex:selectList inside the header facet of a pageBlock and it doesn't appear to work.  Is this something I should be able to do?


Thanks.

Why Reset functionality is so complex and hard to implement . I am trying since last 3days to reset a inputTextBox and inputField of type PickList ,but I am still not able to do so .

I searched a lot on discussion board and posted my code also . but nobody was to solve that .

 

plzzzzzzzzz help me if anybody can solve it.

thanks a lot in advance

Hi


I am trying to get some data from a list to Page block table in VF page.

I have used an OUTPUT PANEL outside and in that I have kept PageBlock Table.


As the record keep on varying the size of Pageblock table varies. I want the size to remain static. If the no. of  records increase then scrollbars should come instead of increased size of pageblock table. (Lets say it should display 10 records only. If more than 10 records are there then scroll bars should come)


I tried keeping Output Panel layout as 'block' and assigning fixed height to it but it does not work exactly when there are many records.


Can anyone provide insight whether how to get the size of Pageblock table or output panel to remain same despite varying no. of records??

Or in any other way this can be done?

Dears

 

I am self learning and apex code manual reader, my company has an important project with one of the most important Telecomunication company in Venezuela , I am trying to save two file obtained from javascript code into account object, I created a controller class that received the three values from javascript, but I cannot take the ID of the current account that I am working, this VS page display a map when you want to update or modify the account info that show me latitude and longitude of the selected point of the map (javascript values), is important to note that I already try setting ID that exist in the account object but it does not work, below the resume code:

 

//controller, it is the name of the class

<apex:page controller="lat_lon_GoogleMap"  >

 

//Javascript values

place.Point.coordinates[0];
place.Point.coordinates[1];

 

//method name of the class with the parameters.

save_lat_lon (place.Point.coordinates[1], place.Point.coordinates[0],Account.Id); //Account.Id setting this value to existing ID does not work.

 

//How to get the ID of the account, before user the controles controller="lat_lon_GoogleMap", I could get the ID through Account.ID but using standarcontrolles="Account", how can I get this ID using controler "lat_lon_GoogleMap". I cannot use both, I got an error from salesforce that I cannot user two controlers.

 

  </apex:page>

 

 

 

/*********************************************** the class (controller)*************************************************/

 

/****clase para almacenar datos del mapa****/
public with sharing class lat_lon_GoogleMap{


    /****metodo que se llama en la pagina para almacenar datos del mapa****/
    public static void save_lat_lon (string lat, string lon, string Account_Id) {//method called in VF page.



//remember that Account_Id value is empty because I cannot get this ID in the VF page.

 

      Account acc = new Account(Id=Account_Id);
        acc.Latitud__c = lat;
        acc.Longitud__c = lon;
        update acc;
 
    }

 

}//class

 

 

 

I hope this explanation is clear for you.

 

Best Regards

  • September 06, 2010
  • Like
  • 0

Hi There,

 

I'm sure this is much easier than I think it is.

 

I am using pageBlockTable to display a list of Products.

 

I want to be able to make the whole row grey if Product.IsActive == false.

 

Is there an easy way?

 

TIA

Does anyone have a good code sample of a Save() method that refreshes the vf page on itself?  OR can help me with my code below?

 

I have a vf form accessed via a sites page ...on save, i want to have the form insert the data and then refresh the newly created page.

 

I tried to do this via onclick action on the command:save ..but doesnt seem to work.

 

here is my current approach (not working)

 

<apex:commandButton action="{!save}" value="Calculate" onclick="back();"/>
 <script type="text/javascript">
function back()
{
window.parent.location.href='{!$Page.FAA_Compensation_Calculator}?id={!$CurrentPage.parameters.id}&txt={!$CurrentPage.parameters.txt}';
}
</script>

 

Tx!

Hi,

 

I have an issue. I want to display in a visualforce page all contacts associated with an opportunity.Some how i am unable to get the data

 

Here is my VF Code :

 

<apex:page StandardController="Opportunity" extensions="OpptyReport" action="(!oppcontacts}">
   
    <apex:pageBlock Title="Sample Report" >
        <apex:pageblockSection Columns="2" >
            <apex:pageBlockTable value="{!AssociatedContacts}" var="cts">           
                <apex:column headerValue="Contact Name">
                    <apex:outputText value="{!cts.Contact.Name}">
                    </apex:outputText>
                 </apex:column>
                 <apex:column headerValue="Contact Role">
                    <apex:outputText value="{!cts.Role}">
                    </apex:outputText>
                 </apex:column>
            </apex:pageBlockTable>                                           
        </apex:pageblockSection>           
    </apex:pageBlock>
</apex:page>

 

Here is My Apex Class:

 

public class OpptyReport {

    public OpptyReport(ApexPages.StandardController controller) {

    }
    
   public List<OpportunityContactRole> cts=new List<OpportunityContactRole>();
   
   public void oppcontacts(){
       cts=[Select contactId, Contact.Name, Role from OpportunityContactRole where  OpportunityId=:Apexpages.Currentpage().getparameters().get('Id')];
       
       //return null;
       }
    public List<OpportunityContactRole> getAssociatedContacts(){
        //System.debug('Contact Role=' + cts.Contact.name);
        return cts;
    
    }

Any help/idea is highly appreciated.

 

Thanks in advance

 

Sales4ce

Hi there

 

I'm trying to hide pageblock buttons in my visual force page using my custom <style></style>. But when I`m rendering it as a pdf, button still appears on the pdf.

 

Could anyone have any idea?

 

I appreciate any comment.

  • March 12, 2010
  • Like
  • 0

Hi All,

 

I am crating the Visualforce page. I use the <dataTable> tag for displaying data, but it does not have any highlight on the selected row same as using <pageBlockTable> tag.

 

Could anyone give me the suggestion, how I can control it? I am very new in visualforce and web coding.

  • March 09, 2010
  • Like
  • 0

I have multiple select lists. I want the second select list to be rendered only after the user makes a selection in the first list. How would I make it happen using VisualForce, any examples would be appreciated.

 

Since the second list is populated after the first, how can I communicate between the first selection and the controller. I do not want the contoller methods associated with the second list execute before user action in the first.

 

Thanks. 

  • March 04, 2010
  • Like
  • 0

I have a very simple VF page:

 

 

<apex:page standardController="Opportunity">

<apex:pageMessages />
<apex:form >

Opp name: <apex:inputField value="{! Opportunity.Name }" />
<br/>
<apex:commandButton value="Save" action="{! save }" />

</apex:form>
</apex:page>

I log in as a System Administrator and load the page with this:  https://c.cs1.visual.force.com/apex/Test?id=006S0000003Br7y

 

The page looks just fine. I type in a new Opportunity name and click Save. The page thinks a little, then redirects me to the regular Opportunity view page, but my new Opportunity name doesn't appear -- it's not getting saved. 

 

I'm logged in as a System Administrator, so it shouldn't be a permissions issue. I can edit the Opp name using the standard edit page just fine, so again, I don't think it's related to permissions.  I'm using the standard controller, although I've tried it with a custom controller, and I see the same results -- no error, but my changes don't get saved.

 

Any ideas?

  • February 25, 2010
  • Like
  • 0
Hi there Is there any property to set PageBlockSection Title size?
  • February 24, 2010
  • Like
  • 0

I have to find out the total students for every grade and term level...

So I am doing a count for every grade level and placing the value in separate strings and then upsert those valued to the object.

For example:

 

numStudents10 = [select count() from Contact where AccountId = :schoolId and Grade__c=10 ]; numStudents11 = [select count() from Contact where AccountId = :schoolId and Grade__c=11 ]; numStudents12 = [select count() from Contact where AccountId = :schoolId and Grade__c=12 ]; numStudents9 = [select count() from Contact where AccountId = :schoolId and Grade__c=9 ];

 Then I have to do separate for terms Like: For all grades....

 

numStudents10_1 = [select count() from Contact where AccountId = :schoolId and Grade__c=10 and Term__c=10.1 ]; numStudents10_2 = [select count() from Contact where AccountId = :schoolId and Grade__c=10 and Term__c=10.2 ]; numStudents10_3 = [select count() from Contact where AccountId = :schoolId and Grade__c=10 and Term__c=10.3 ]; numStudents10_4 = [select count() from Contact where AccountId = :schoolId and Grade__c=10 and Term__c=10.4 ];

 Does anyone have a better way to do this??

Thanks

 

 

 

 

Hi.

I setup CustomObject and CustomItem.

the CustomItem(RevisionLength__c) is numeric value.

the CustomItem(PreRevisionDate__c) is date value.

I create the trigger.

 

 

trigger updateDeviceMng on DeviceMng__c (before insert, before update) {
Map<ID, ModelVL__c> model = new Map<ID, ModelVL__c>(
[select Id, Name, RevisionLength__c, LifePeriod__c, ReplacementCycle__c from ModelVL__c]);
for(DeviceMng__c d: Trigger.new){
System.debug(model.get(d.Model__c).RevisionLength__c);
for(Integer i=0; i<m.size(); i++){
d.NextRevisionDate__c = d.PreRevisionDate__c.addYears(model.get(d.Model__c).RevisionLength__c);
}
}
}

 

When save it, happend the error. 

 Save error: Method does not exist or incorrect signature: [Date].addYears(Double)

 

so, I change the code.

d.NextRevisionDate__c = d.PreRevisionDate__c.addYears((model.get(d.Model__c).RevisionLength__c).initValue);

 But happend the error.

 Save error: Initial term of field expression must be a concrete SObject: Double

 

Why the CustomItem is Double?(I think it is Integer)

Why don't use initValue? 


If you understand the reason, please tell me.
 
Thanks. 

How would I get the value of the select list using javascript section in my visualforce page

 

<apex:selectList id="queryDurationSelect" value="{!FilterDateValues}" size="1">

<apex:selectOptions value="{!FilterItems}"/>

</apex:selectList>

 

  

getFilterDateValues just returns a String[] of the select list values

- Jason 

Hi all;

I have a VF page, custom component and controller class.

In order to be easily understood I simplified those as below. You can simply copy and paste them.

Component:

<apex:component controller="MyClass">
  <apex:attribute name="content" type="Object" assignTo="{!content}" description=""/>

  {!content}
</apex:component>

Controller:

public with sharing class MyClass {
    Object content = null;

    public void setContent(Object obj) {
      this.content = obj;
    }
    
    public Object getContent() {
      return this.content;
    }
}

 VF Page:

<apex:page standardController="Opportunity">
    <c:aTest content="{!Opportunity.name}"/>
</apex:page>

 

 

These are work fine. But if I changed the content of the <c:aTest> component to a Double value as below 

<c:aTest content="{!Opportunity.amount}"/>

 

It gives me the following error.

"Unsupported type java.math.BigDecimal encountered."

 

This is the only error message I get. As I understood the data type 'Double' can't be stored in a variable of Object data type when the value is passed through a component. If so, this shouls be a bug of Salesforce.

Can anybody help me to solve this problem. Thank you.

Hello All;

I have a dynamic SOQL query which is called as below.

 

public Account[] getAccounts() {
    String userInput = Apexpages.currentPage().getParameters().get('param');
    Account[] accs = database.query('SELECT name FROM Account 
                        WHERE name = \'' + userInput + '\'');
    return accs;
}

 Here I expect a name of an Account as the userInput.

But as I think a SOQL injection can be done in the above case since the user can input something as below as the the 'param'.

param=Account1' OR name<>'xxx

In above case the user gets data of all the accounts instead of what I expected to return.

But as I think If I have used the "with sharing" keyword in my controller class the user still can't see the records which are not permitted for him.

Am I correct or is still there a way(Security hole) for user to view unauthorized data.

Thanks

 

 

 

 

 

 

Hi all;

I have several opportunities and I want to restrict some users by viewing data of some Opportunities. I like to assign users to various user-roles and then let those roles to access only pre-defined Opportunities. It means users under some roles can't access(view / edit) some opportunities. Is there a way to do this? Can I use user-roles to accomplish this kind of a task? (If my question is not clear I'm ready to explain further.)

Thanks.

Hi all;

Is there a way for an administrator to prevent a user from accessing certain opportunities(not all opportunities). It means the user could access only the opportunities that the administrator has allowed.

Hi all;

I have several questions about Salesforce CRM Content.

1. Can I upload a file to Salesforce CRM Content by using Apex code? If so please tell how can I do that.

2. Can I display an image uploaded to Salesforce CRM Content on a visualforce page?

3. Is there a sObject which represents the Salesforce CRM Content, so that I can query data from that sObject?

 

If anybody knows an answer for at least one question please help me. If any question is not clear I'm ready to explain further. Thanks.

I used SF Metadata API(18.0) to check whether a page exist in a given account using existing sessions.
I used existing session ID to connect SF through Metadata API. 
I have two SF accounts for test purposes. Both accounts have session expiry over 2 hours.
But Metadata API does not work for one of the two accounts.
(Further I see both the accounts work fine with the SF web service API)
 
Could anyone please point out why Metadata API successful only in one account? Please see the below error trace:
 
AxisFault
 faultCode: {http://soap.sforce.com/2006/04/metadata}INVALID_SESSION_ID
        at org.apache.axis.message.SOAPFaultBuilder.createFault(SOAPFaultBuilder.java:222)
 faultSubcode:
        at org.apache.axis.message.SOAPFaultBuilder.endElement(SOAPFaultBuilder.java:129)
        at org.apache.axis.encoding.DeserializationContext.endElement(DeserializationContext.java:1087)
        at com.sun.org.apache.xerces.internal.parsers.AbstractSAXParser.endElement(AbstractSAXParser.java:601)
 faultString: INVALID_SESSION_ID: Invalid Session ID found in SessionHeader: Illegal Session. Session not found, missing session key:
Hi all;
  Is there a way to create a new field in a sObject by using Apex code.
  For an example I want to create a field named "OpportunityNumber" at run time.
  
 
I want something similar to following code.
  
  Opportunity.createNewField('OpportunityNumber'); 
The following code works fine when the API version of the page is set to 17. The output pdf page is rendered with two outputPanels which touch each other and everything is ok.
But it doesn't work correctly if I change the API version to 18. Now it shows a gap between two outputPanels.
And if I removed the line "<apex:outputField value="{!Opportunity.name}"/>", the code doesn't work both
under version 17 and 18.
Can anybody help me to fix this problem.
 

<apex:page renderAs="pdf" standardController="Opportunity">

<apex:outputPanel style="border:solid 1px red;height:200px; position:fixed; width:100%;">

</apex:outputPanel>

<apex:outputPanel layout="block" style="border:solid 1px green;position:relative; top:200px; height:200px">

</apex:outputPanel>

<apex:outputField value="{!Opportunity.name}"/>

</apex:page>

 

 

Hi all;

I have the following Controller class and Page.

 Controller: 

public class MyClass {

public List<Opportunity> getOpportunityList() {

List<Opportunity> oppList = new List<Opportunity>();

for (Opportunity[] opp : [SELECT id, (SELECT id FROM OpportunityLineItems) FROM

Opportunity WHERE name LIKE '%ABC%']) {

for (Opportunity o : opp) {

oppList.add(o);

}

}

return oppList;

}

} 

  Page: 

<apex:page controller="MyClass">

<apex:repeat value="{!opportunityList}" var="op">

<apex:datatable value="{!op.OpportunityLineItems}" var="item">

<apex:column value="{!item.id}"/>

</apex:datatable>

<hr/>

</apex:repeat>

</apex:page> 

 My problem is, when the total number(SUM) of OpportunityLineItems in all of the Opportunities returned by my qyery is greator than 200, the VFPage shows an incorrect number of OpportunityLineItem rows.

 For an example if my query returns two Opportunities each has 100 LineItems, in the VF page I can Only see 101 LineItems.

Other LineItems are vanished. 

   When I use the following Syntax it works well. 

List<Opportunity> oppList = [SELECT id, (SELECT id FROM OpportunityLineItems) FROM Opportunity WHERE name LIKE '%ABC%'];

  But in my actual case It is not practical to use this method.

Can anybody explain the reason for the error. If the information supplied by me is not clear enough, I am ready to clarify further. Thanks.

 

 

Message Edited by prageeth on 11-22-2009 10:41 PM

Hi All;

I know it is required to have a 75% of test coverage in order to upload a package. And I know that if a test method fails at the moment the user installs my package, he gets an error.

What I want to know is that is it required to have a 75% of test coverage, at the moment that the user installs my package in his organization.

(Ex:- According to the data in users organization test coverage can be less that 75%. I want to know whether it is allowed.) 

 

(If my question is not clear enough, Im ready to supply more info.)  

 

Message Edited by prageeth on 11-10-2009 08:07 PM

Hello;

  I have a problem that I can't atleast guess the reason. I have following VF page

<apex:page renderAs="pdf" standardController="opportunity">

    <apex:datatable value="{!opportunity}" var="v" style="width:100%;border:solid green 1px;">

        <apex:column width="25%" style="border:solid green 1px;">

            <apex:facet name="header">

                <DIV style="border:solid red 1px;width:100%;">

                    This text should be wrapped because it is too long. 

                </DIV>

            </apex:facet>

        </apex:column>


        <apex:column width="75%" style="border:solid green 1px;">

            <apex:facet name="header">

                <DIV style="border:solid red 1px;width:100%;">

                    This is second column. 

                </DIV>

            </apex:facet>

        </apex:column>

    </apex:datatable>


    <apex:datatable value="{!opportunity}" var="v2" style="width:100%;border:solid green 1px;">

        <apex:column value="{!opportunity.name}"/>

    </apex:datatable>

</apex:page>

 

My problem is the first DIV in first table doesn't  wrap the text inside it. Instead it lets the text to expand outside the DIV.

But if I removes the value="{!opportunity.name}" part in second table it wraps the text and works nicely.

If I changed the value as  value="{!opportunity.id}" or as any other thing, the error occures.

Or if I put a value attribute in the first table the same error occures.

Can anybody explain me what the problem is. I'm ready to supply more info at any time. Thanks.

    I am trying to create an application, by using which the user can see his salesforce data even if he is offline. I am using adobe AIR and Flex with 'as3SalesforceAIR' and 'as3Salesforce' libraries.
Following is a part of code in my application.
   
        var lreq:LoginRequest = new LoginRequest({
    username: txtUserName.text,
    password: txtPassword.text,
    callback: new AsyncResponder(function (result:Object):void {
       })});
       airConnection.login(lreq);
       getOpportunities();

     <airforce:AIRConnection id="airConnection"/>

    In the getOpportinities() function I have the code which queries the required salesfore data.
My problem is, when the user runs my application for the very first time it gives an error. As I believe this occurs because the getOpportunities() function runs as soon as the "airConnection.login(lreq);" line is executed. As I think the "airConnection.login(lreq)" method requires a little time to complete the login process. But before it gets completed the "getOpportunities()" method starts to run. Therefore an error occurs because data can't be queried until the login process is completed.
    Sometimes the reason for the problem may be another one. Can anybody suggest an idea about my problem? or is there a method to delay the execution of "getOpportunities()" method until the login process is completed. Thank you.
Dear all,
        I have uploaded an app in to the AppExchange. I have installed LMA in my account and using a workflow rule to get an email notification when somebody installed my app. Now I want to get an email notification when a customer uninstalled my app.
        In 'LMA User Guide' they say that "License status" can be used to track the uninstallation. They say that "License status" is automatically changed in to "Uninstalled" when the app is uninstalled. But even after the app is uninstalled I can see the "License status" still stays unchanged(It means "Active"). How can I manage this problem. Please help....Thanks...
        


Message Edited by prageeth on 12-16-2008 12:16 AM
Dear all, I assigned a workflow rule so that I receive an email alert when new Lead is created. I selected criteria as "Last name not equal xxxx". The rule works nicely and I receive an email according to my email template at every time I create a new Lead Manually(By opening leads tab and creating new lead).
I have uploaded a managed package to the AppExchange. I want to receive an email alert when somebody installed my package. I used LMA(License management app) and now, when somebody installs my package a new lead is automatically added to my Lead table. It means(as I think) LMA settings are ok.  But the problem is I do not receive an email alert. But I can see a new lead has been created. I can't understand where is the problem. Please help:smileysad:...

Having some issues figuring this one out.  This is what i need:

  • Display a table, reach row displaying id, username, and a command button
  • When the command button is clicked, take the ID of the record on that row and send it to a method on the controller where it will be output using a system.debug.

Visualforce

 

<apex:page controller="vftest">
    <apex:form > 
        <apex:pageBlock >
            <apex:dataTable value="{!TestUsers}" var="tu">
                <apex:column headerValue="Id">
                    <apex:inputField value="{!tu.Id}"/>
                </apex:column>
                <apex:column headerValue="UserName">
                    <apex:inputField value="{!tu.UserName}"/>
                </apex:column>
                <apex:column>
                    <apex:commandButton action="{!TestParams}" value="TestParam">
                        <apex:param name="testuser" value="{!tu.UserName}"/>
                    </apex:commandButton>
                </apex:column>
            </apex:dataTable>
        </apex:pageBlock>
    </apex:form>
</apex:page>

 

Class

 

public class vftest
{
    string selected_user;

    public List<User> getTestUsers()
    {
        List<User> testuserlist = [select id, username from user where user_type__c = 'Test'];
        return testuserlist;
    }
    
    
    public void TestParams()
    {
        Id id1 = ApexPages.currentPage().getParameters().get('testuser');
        system.debug('-----------------tp-id1-------------------' + id1);
        
        Id id2 = System.currentPageReference().getParameters().get('testuser');
        system.debug('-----------------tp-id2-------------------' + id2);    
    }    
}

 

Any help would be appreciated.

 

 

Hi Guys,

 

I have a datalist which lists records based on certain criteria and with each record I include a button too. I have the button coded to show or hide an OutputPanel relative to it's row in the datalist. The problem is that I can't seem to get the button to perform the task for a single item in the datalist. It will only show or hide every OutputPanel in the list.

 

I've tried playing with the var attribute but haven't found anything that works.

 

Hope you can help.

 

Regards,

 

Paul

 

 

I have a text field that i want to trim and have been trying with substring:

 

 

Field_Name__c.substring(5,27);

 However i get errors

System.StringException: Ending position out of bounds: 28

 When the field is less than 32 characters. It works fine if i say (5,10) as all have at least 15 characters.

 

 

 

Any tips on how i can trim this to ignore the first 5 characters and then return no more than 27 after that.

 

 

  • October 21, 2010
  • Like
  • 0

Hi,

 

how to get date selector beside a field of type date in vf page.

 

 

for example:

fromDate

 

it could be possible with <apex:inputfield/>(it will come automatically) but i am not using the same standard controller in the page.

 

here the fromdate field's object is different from the object mentioned in the standardcontroller.

 

 

Hi All,

 

Is it possible to make use of URLFOR based on condition like given below

 

 

"{!URLFOR($Resource.Stylesheets, '{!IF(true, "images/red_bg.png","images/blue_bg.png" )}' )}"

 

 

If it is possible kindly provide a sample example.

 

Any help regarding this will be appreciated.

 

Thanks in Advance.

  • October 20, 2010
  • Like
  • 0

I am working in a Custom Opportunity Clone and am trying to clone the Sales Team when I recieve the following error when I click the clone button:

System.DmlException: Insert failed. First exception on row 0 with id 00q50000002eoQZAAY; first error: INVALID_FIELD_FOR_INSERT_UPDATE, cannot specify Id in an insert call: [Id]



Class.OpportunityCloneWithItemsController.MyClone: line 94, column 14 External entry point 

 

Here is the code in question to clone the sales team:

             // copy over the Opportunity Sales Team - ONLY INCLUDE THE FIELDS YOU WANT TO CLONE
             List<OpportunityTeamMember> team= new List<OpportunityTeamMember>();
             for (OpportunityTeamMember otm : [Select id, TeamMemberRole,OpportunityAccessLevel, 
                  Userid, opportunity.id From OpportunityTeamMember where Opportunity.id = :o.id]) {
                  OpportunityTeamMember newotm = otm.clone(true);
                  newotm.opportunity = otm.Opportunity;
                  team.add(newOtm);
             }
             insert team;
      

 

Here is the entire code:

 

public with sharing class OpportunityCloneWithItemsController {

    //added an instance varaible for the standard controller
    private ApexPages.StandardController controller {get; set;}
     // add the instance for the variables being passed by id on the url
    public Opportunity o {get;set;}
    // set the id of the record that is created -- ONLY USED BY THE TEST CLASS
    public ID newRecordId {get;set;}


    public OpportunityCloneWithItemsController(ApexPages.StandardController controller) {

        //this.controller = controller;

        // load the current record
        o = (opportunity) controller.getRecord();
        system.debug('********** ' + o);
    }
    
    // method called from the VF's action attribute to clone the Opportunity
    public PageReference MyClone() {
 
         // setup the save point for rollback
         Savepoint sp = Database.setSavepoint();
         Opportunity o;
         Opportunity newO;
 

              //copy the Opportunity - ONLY INCLUDE THE FIELDS YOU WANT TO CLONE
             o = [select 
                     Name, 
                     Estimated_Cost__c, 
                     Margin__c, 
                     Competitor_Primary__c,
                     Competitor_Secondary__c, 
                     Account_Shipping_Location__c, 
                     Amount, 
                     INCO_Terms__c,             
                     Related_Location__c, 
                     Language_to_prepare_docs_in__c, 
                     Campaignid, 
                     Equipment__c,             
                     Parent__c, 
                     Equip_Services_Options_to_be_quoted__c, 
                     Lead_Time_Ex_Works__c, 
                     Op_Market_Position__c,             
                     Product_1__c, 
                     Product1_condition__c, 
                     Product1_Line_Capacity__c, 
                     Product1_Bulk_density__c,
                     Product1_defect_description__c, 
                     Product_2__c, 
                     Product_2_Condition__c, 
                     Product_2_Line_Capacity__c,
                     Product_2_Bulk_Density__c, 
                     Product_2_Defect_Description__c, 
                     Description, 
                     PS__c, 
                     Farmco__c,
                     Service_Contract__c, 
                     Potato__c, 
                     Processed_Fruit_Veg__c, 
                     AIS__c, 
                     Project_System_Eng__c, 
                     Freshline__c,
                     Spare_Parts__c, 
                     Pharma__c, 
                     Misc_Other__c, 
                     CloseDate, 
                     StageName, 
                     AccountId,
                     OwnerID from Opportunity where ID = :this.o.ID];
             newO = o.clone(false);

    newO.Name = 'Cloned - ' + o.Name;
    newO.StageName = 'Prospecting';
    newO.CloseDate = o.CloseDate + 700;
    
             insert newO;
         System.debug('******* ID: ' + newO.ID);
    
    //Reset the Opp ID and resset fields to default values

    

             // copy over the Opportunity Sales Team - ONLY INCLUDE THE FIELDS YOU WANT TO CLONE
             List<OpportunityTeamMember> team= new List<OpportunityTeamMember>();
             for (OpportunityTeamMember otm : [Select id, TeamMemberRole,OpportunityAccessLevel, 
                  Userid, opportunity.id From OpportunityTeamMember where Opportunity.id = :o.id]) {
                  OpportunityTeamMember newotm = otm.clone(true);
                  newotm.opportunity = otm.Opportunity;
                  team.add(newOtm);
             }
             insert team;
      


     return new PageReference('/'+newO.id+'/e?retURL=%2F'+newO.id);
   return new PageReference('/'+  newO.Id);

    }

}

 

How do I solve this error?

 

Thank you

Hello

 

Please can anyone tell me how to use collections f apex, i.e. Sets & Lists. am new to salesforce and don't knw that much about sets & Lists. anyonetell me how we can declare thenm in apex clss or visualforce page? and how its work? and how to save the value of e.g. 5 sets in one list???

 

i want to create a 5 sets in one list , is that possible? and pls explain how to save that list ? if any one have example code then pls post that.

 

 

Thanks In advance.

hi,

When a user views a detail page and rolls over a field value, they get a little pencil icon on the right and can then click and edit the value. How can I do this on a visualforce page?

Thanks for you help!!

  • October 14, 2010
  • Like
  • 0

Hi,

I have a custom button that sends order information to another system.  The button's content Source is a visualforce Page.  The visualforce page's controller does the transfer of data by calling a webservice.  The vpage then displays the response of the webservice.

 

The problem we are running into is the users are double clicking the button.

 

I figured I would disable the button after the first click, but I cannot figure out how to do that.  I need the button disabled as soon as the user clicks the button.  I can't disable it on the visual force page because to much time has elapsed before the disable will take place. I thought I would try disabling it in the controller but I don't know how to do that.

 

Can anyone help?

I have run into this problem in a few places with Contract. It's pretty obvious that Contract has an Id, as it is visible in the URL for the individual contract.

 

I am creating a custom button and I need to use the Id to load up the correct Contract in my visualforce page. The page works fine if I manually paste in the Id. The button is set to "URL" as the content source, and the following code is used: 

 

 

apex/PDAdContract?id={!Contract.Id}

So, why would it say that Contract has no Id? How can I get the Id?

 

THanks! 

 

Hello Everyone,

 

I am facing some problem in command button. pls help me if anyone knw.

 

I want when i click on command button it opens the new pageblocksection with some of values. i am using javascript for the same with onclick event, it shows the pageblocksection but for some time and then refresh the page. if anyone knw pls tell me the error.

 

or if their any other solution for this??????

 

code that am using.... pls check.

<apex:page controller="TimeTable" sidebar="false">
 <script> 
        
    function Function()
    {   
         document.getElementById('idSpan').style.display = 'block';
                
    }
 </script>
<apex:form >
<apex:pageBlock title="Time Table">
<apex:pageBlockButtons location="bottom">
<apex:commandButton value="Save" action="{!save}"/>
<apex:commandButton value="Cancel" action="{!cancel}"/>
</apex:pageBlockButtons>
<apex:pageBlockSection >
<apex:inputField value="{!timetable.Date__c}"/>
<apex:inputField value="{!timetable.Class__c}" />
<center><apex:commandButton value="Create Time Table" onclick="Function();"/></center>
</apex:pageBlockSection>
<span id="idSpan" style = "display:none">
<apex:pageBlock >
<apex:pageBlockSection title="Time Table" columns="1" id="Details">
<table>
<tr><th width="100">Period</th><th width="100">MON</th><th width="100">TUE</th><th width="100">WED</th><th width="100">THU</th>
<th width="100">FRI</th><th width="100">SAT</th></tr>
<tr><td width="100">Period-1<br/>8:00-9:00 AM</td><td width="100"><apex:inputField value="{!timetable.Teacher__c}"/></td><td width="100"><apex:inputField value="{!timetable.Teacher__c}"/></td><td width="100"><apex:inputField value="{!timetable.Teacher__c}"/></td><td width="100"><apex:inputField value="{!timetable.Teacher__c}"/></td>
<td width="100"><apex:inputField value="{!timetable.Teacher__c}"/></td><td width="100"><apex:inputField value="{!timetable.Teacher__c}"/></td></tr>
</table>
</apex:pageBlockSection>
</apex:pageBlock>
</span>
</apex:pageBlock>
</apex:form>
</apex:page>

 Thanks In Advance.

 

Hello All;

I have a dynamic SOQL query which is called as below.

 

public Account[] getAccounts() {
    String userInput = Apexpages.currentPage().getParameters().get('param');
    Account[] accs = database.query('SELECT name FROM Account 
                        WHERE name = \'' + userInput + '\'');
    return accs;
}

 Here I expect a name of an Account as the userInput.

But as I think a SOQL injection can be done in the above case since the user can input something as below as the the 'param'.

param=Account1' OR name<>'xxx

In above case the user gets data of all the accounts instead of what I expected to return.

But as I think If I have used the "with sharing" keyword in my controller class the user still can't see the records which are not permitted for him.

Am I correct or is still there a way(Security hole) for user to view unauthorized data.

Thanks

 

 

 

 

 

 

Hi,

 

I'm trying to put an apex:selectList inside the header facet of a pageBlock and it doesn't appear to work.  Is this something I should be able to do?


Thanks.

Why Reset functionality is so complex and hard to implement . I am trying since last 3days to reset a inputTextBox and inputField of type PickList ,but I am still not able to do so .

I searched a lot on discussion board and posted my code also . but nobody was to solve that .

 

plzzzzzzzzz help me if anybody can solve it.

thanks a lot in advance

Hi all;

I have several opportunities and I want to restrict some users by viewing data of some Opportunities. I like to assign users to various user-roles and then let those roles to access only pre-defined Opportunities. It means users under some roles can't access(view / edit) some opportunities. Is there a way to do this? Can I use user-roles to accomplish this kind of a task? (If my question is not clear I'm ready to explain further.)

Thanks.