• split
  • NEWBIE
  • 25 Points
  • Member since 2009

  • Chatter
    Feed
  • 1
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 3
    Questions
  • 17
    Replies

Hello,

           I am having two custom object (dml1__c and dml2__c). The relation between these two object is Lookup Relationship. I want to update the record within the click. Here is the code which i tried.

 

 

public void updateDml2(){
        List<dml2__c> d2 = [SELECT name, Last_Name__c, Other__c, dml1__r.name, dml1__r.Summary__c FROM dml2__c WHERE name =: dName];
        for(dml2__c dm2 : d2){
            dm2.Last_Name__c = lName;
            dm2.Other__c = sum;
            dm2.dml1__r.Summary__c = sum;
            update dm2;
        }
    }

 

 

In the above code when I click the update button the record is updated successfully in dml2__c custom object but the record of dml1__c custom object remains unchanged. Is there any way to do this correctly or guide where I am going wrong.

Any help will be highly appreciable.

 

Thanks

Raju

I have:

Controller:
...
List<X__c> = [SELECT Id, (SELECT Id, Y_value1__c, Y_value2__c FROM Y__r) FROM X__c];
...


Page:
...
<apex:pageBlockTable value="{!X__c}" var="x">
<apex:column value="{!x.Id}"/>
<apex:column>
<apex:pageBlockTable value="{!X__c.Y__r}" var="y">
<apex:column value="{!y.Id}">
<apex:column value="{!y.Y_value1__c}">
<apex:column value="{!y.Y_value2__c}">
</apex:pageBlockTable>
</apex:column>
</apex:pageBlockTable>
...

-----------------------------------------------
x.Id1 |y.Id1 |y.Y_value1__c |y.Y_value2__c |
|y.Id2 |y.Y_value1__c |y.Y_value2__c |
-----------------------------------------------
x.Id2 |y.Id1 |y.Y_value1__c |y.Y_value2__c |
|y.Id2 |y.Y_value1__c |y.Y_value2__c |
|y.Idn |y.Y_value1__c |y.Y_value2__c |
-----------------------------------------------
x.Idn | |y.Y_value1__c |y.Y_value2__c |
... |... |... |... |




How do this???? ->
------------------------------------------------------------------------
x.Id1 | y.Id1 | y.Id2 |
----------------------------------------------------------------
|y.Y_value1__c |y.Y_value2__c |y.Y_value1__c |y.Y_value2__c |
--------------------------------------------------------------------------------------------------------
x.Id2 | y.Id1 | y.Id2 | y.Idn |
------------------------------------------------------------------------------------------------
|y.Y_value1__c |y.Y_value2__c |y.Y_value1__c |y.Y_value2__c |y.Y_value1__c |y.Y_value2__c |
--------------------------------------------------------------------------------------------------------
x.Idn | y.Id1 | y.Idn | ... |
------------------------------------------------------------------------------------------------
|y.Y_value1__c |y.Y_value2__c |y.Y_value1__c |y.Y_value2__c |... |... |
--------------------------------------------------------------------------------------------------------

 

  • March 11, 2010
  • Like
  • 0

 this is first trigger

trigger chAccGenerate on Organization__c (after insert) {
      if (Trigger.isInsert){
      List<Chart_of_accounts__c> accounts = new Chart_of_accounts__c[0];
      List<SMain__c> smain = new SMain__c[0];
        for (Organization__c o : Trigger.new) {        
            if(o.Industry__c == 'Telecom')
             {accounts.add(new Chart_of_accounts__c (name = 'Sales of product income',Type__c = 'Income',Organization__c = o.ID));
            accounts.add(new Chart_of_accounts__c (name = 'Service/fee income',Type__c = 'Income',Organization__c = o.ID));
            insert accounts;
            }
            
}
}
}

 

 

 

trigger test on Chart_of_accounts__c (after insert) { if (Trigger.isInsert){ List<SMain__c> smain = new SMain__c[0]; for (Chart_of_accounts__c c : Trigger.new) { if(c.Type__c == 'Income') {smain.add(new SMain__c (Chart_of_accounts__c = c.ID)); insert smain; } } } }

 

 

 after create Organization__c record force say:

 

 Error: Invalid Data.
Review all error messages below to correct your data.
Apex trigger CloudBudget.chAccGenerate caused an unexpected exception, contact your administrator: CloudBudget.chAccGenerate: execution of AfterInsert caused by: System.DmlException: Insert failed. First exception on row 0; first error: CANNOT_INSERT_UPDATE_ACTIVATE_ENTITY, CloudBudget.test: execution of AfterInsert caused by: System.DmlException: Insert failed. First exception on row 0 with id a0AA0000000EdM1MAK; first error: INVALID_FIELD_FOR_INSERT_UPDATE, cannot specify Id in an insert call: [Id] Trigger.CloudBudget.test: line 7, column 13: []: Trigger.CloudBudget.chAccGenerate: line 9, column 13

 

 

???

 

 

  • January 06, 2010
  • Like
  • 0

trigger headqarterCreate on Organization__c (after insert) {

if (Trigger.isInsert) {List<Business_units> units = new Business_units__c[0];
for (Organization__c o : Trigger.new) {units.add(new Business_units__c
(name = o.Headquarter_company_name__c));}
insert units;

}
}

 

After insert Organization__c record

force say

 

 

Error: Invalid Data.
Review all error messages below to correct your data.
Apex trigger CloudBudget.headqarterCreate caused an unexpected exception, contact your administrator: CloudBudget.headqarterCreate: execution of AfterInsert caused by: System.DmlException: Insert failed. First exception on row 0; first error: REQUIRED_FIELD_MISSING, Required fields are missing: [CloudBudget__Organization__c]: [CloudBudget__Organization__c]: Trigger.CloudBudget.headqarterCreate: line 5, column 7

 

 

 

???

Message Edited by split on 01-06-2010 06:20 AM
  • January 06, 2010
  • Like
  • 0

If use

 

<input type="checkbox" value="Bike" checked="{IF(false,'checked' ,'')}"/>

Always checkbox is checked. But it should be unchecked

 

 If use

 

<input type="checkbox" value="Bike" checked=""/>

 Checkbox is unchecked

 

  What is the different of

    checked="{IF(false, ‘checked' ,'')}" & checked=""

 

How I toggle checked state dynamically with a custom condition ?.

(Salesforce.com API  VF page version is 19.0)

 

-Suresh

  • July 30, 2010
  • Like
  • 0

I am trying to create a page that will open several links in new windows. I've tried several methods which dont work and am now  beginning to think that salesforce does not allow the opening of new pages. For example:

 

 

<apex:page standardcontroller="Account" extensions="maininvoice">
 <body>
  <p id="hello">Hello World</p>
  <a href="http://www.google.com" class="name">google</a>
  <a href="http://www.yahoo.com" class="name">yahoo</a>
</body>

    <apex:includeScript value="{!URLFOR($Resource.jquery, 'js/jquery-1.4.2.min.js')}"/>
<script type="text/javascript">

var j$ = jQuery.noConflict();
j$(function(){
  $('.name').each(function() {
    window.open(this.href);
  });
});
 
</script>

</apex:page>

does not work in salesforce but if I do it outside of salesforce it does: http://jsbin.com/adome/edit

 

 

Hi All,

 

I have a Date Time feild which is diplayed in the US Time Format. I need to show that in the European Date Format in the Visual force page.Currently, I am using Inputfield to display the Date Time field.

 

How to show the Date Time field in the European Date Format?

 

Thanks

Hello,

           I am having two custom object (dml1__c and dml2__c). The relation between these two object is Lookup Relationship. I want to update the record within the click. Here is the code which i tried.

 

 

public void updateDml2(){
        List<dml2__c> d2 = [SELECT name, Last_Name__c, Other__c, dml1__r.name, dml1__r.Summary__c FROM dml2__c WHERE name =: dName];
        for(dml2__c dm2 : d2){
            dm2.Last_Name__c = lName;
            dm2.Other__c = sum;
            dm2.dml1__r.Summary__c = sum;
            update dm2;
        }
    }

 

 

In the above code when I click the update button the record is updated successfully in dml2__c custom object but the record of dml1__c custom object remains unchanged. Is there any way to do this correctly or guide where I am going wrong.

Any help will be highly appreciable.

 

Thanks

Raju

Hi,

 

I am following this tutorial - http://www.salesforce.com/us/developer/docs/pages/Content/pages_quick_start_hello_world.htm

 

I don't seem to be able to find create page link and page editor at the footer of the page.

 

I am on enterprise edition and I had the developer mode enabled.

 

Please can someone help?

 

Thanks, 

  • February 10, 2010
  • Like
  • 0

Hi all,

 

I am just wondering if you know of any good books (resources) where I can kick start the learning of Visualforce development from basic to intermediate or to advanced level...

 

I am afraid to admit that I have basic programming language experience...

 

Many thanks  

  • February 10, 2010
  • Like
  • 0

Hi,

I have a simple SOSL like this "Select Title from ContentVersion". However I don't know how to

display the returned result in Visual Force page. Please help.

 

thanks

Paul

 

  • February 10, 2010
  • Like
  • 0

I believe this is easily accomplished using a Visualforce page but I cannot find any reference to previous posts. So I could use some help getting started.

 

When users click on the Cases tab, we simply want a custom view displaying all open cases rather than all recent cases. They still need the other functionality on the Cases tab, just change the view from recent to open.

 

I tried accomlishing this by creating a custom web tab using a javascript reference to the URL for the custom view to be displayed. But it created a cross site scripting error.

  • February 09, 2010
  • Like
  • 0

I am getting the "too many dml statements" error when I do a bulk update.  I realize that the problem is that I have an insert statement inside a for loop but I am unsure of how to resolve the issue.  How do I get the fields I want to update into a map or list so that I can then update them all at once?  I am confused about the syntax...Here is the portion of my code that is giving me a problem... thanks!!!!!

///Part 2 B update //if health, update the health market if (HealthGo) { for(Account a: accts){ a.Health_Market__c=Market; a.Health_Renewal_Date__c=RenewalDate; a.Health_Underwriter_Assigned__c = Underwriter; update accts; } } else{ } //if dental, update the dental market if (DentalGo) { for(Account a: accts){ a.Dental_Market__c=Market; a.Dental_Renewal_Date__c=RenewalDate; update accts; } }

 

  • February 09, 2010
  • Like
  • 0

Hello, forum:

 

[Similar question to one I asked in a different thread...]

 

I've created a VF page for creating new child objects from a related list on a parent.  This page has a pageBlock at the top of the page where parent values are displayed.  The 'name' field of the parent displays just fine, but another custom field within the parent does not display.

 

I have this line in my VF page:

 

 

<apex:outputField id="projectName" value="{!Solicitor__c.SOL_Bidding_Opportunity__r.BO_Project_Name__c}"/>

 

But this field doesn't display.

 

My controller extension looks like this:

 

 

public class solicitorExtension { public solicitorExtension(ApexPages.StandardController controller) { Solicitor__c sol = (Solicitor__c)controller.getRecord(); //if you always create the child object through relatedList //parent should not be null if (sol.SOL_Bidding_Opportunity__c != null) { Bidding_Opportunity__c bo = [select BO_Bid_Due_Date_Time__c, BO_Project_Name__c from Bidding_Opportunity__c where id =: sol.SOL_Bidding_Opportunity__c limit 1]; sol.SOL_Bid_Due_Date_Time__c = bo.BO_Bid_Due_Date_Time__c; sol.SOL_Revision_Number__c = 'ORIG'; sol.SOL_Status__c = 'Prospective'; } } }

 

What am I doing wrong?

 

Thank you.

 

 

 

  • February 05, 2010
  • Like
  • 0

 this is first trigger

trigger chAccGenerate on Organization__c (after insert) {
      if (Trigger.isInsert){
      List<Chart_of_accounts__c> accounts = new Chart_of_accounts__c[0];
      List<SMain__c> smain = new SMain__c[0];
        for (Organization__c o : Trigger.new) {        
            if(o.Industry__c == 'Telecom')
             {accounts.add(new Chart_of_accounts__c (name = 'Sales of product income',Type__c = 'Income',Organization__c = o.ID));
            accounts.add(new Chart_of_accounts__c (name = 'Service/fee income',Type__c = 'Income',Organization__c = o.ID));
            insert accounts;
            }
            
}
}
}

 

 

 

trigger test on Chart_of_accounts__c (after insert) { if (Trigger.isInsert){ List<SMain__c> smain = new SMain__c[0]; for (Chart_of_accounts__c c : Trigger.new) { if(c.Type__c == 'Income') {smain.add(new SMain__c (Chart_of_accounts__c = c.ID)); insert smain; } } } }

 

 

 after create Organization__c record force say:

 

 Error: Invalid Data.
Review all error messages below to correct your data.
Apex trigger CloudBudget.chAccGenerate caused an unexpected exception, contact your administrator: CloudBudget.chAccGenerate: execution of AfterInsert caused by: System.DmlException: Insert failed. First exception on row 0; first error: CANNOT_INSERT_UPDATE_ACTIVATE_ENTITY, CloudBudget.test: execution of AfterInsert caused by: System.DmlException: Insert failed. First exception on row 0 with id a0AA0000000EdM1MAK; first error: INVALID_FIELD_FOR_INSERT_UPDATE, cannot specify Id in an insert call: [Id] Trigger.CloudBudget.test: line 7, column 13: []: Trigger.CloudBudget.chAccGenerate: line 9, column 13

 

 

???

 

 

  • January 06, 2010
  • Like
  • 0

trigger headqarterCreate on Organization__c (after insert) {

if (Trigger.isInsert) {List<Business_units> units = new Business_units__c[0];
for (Organization__c o : Trigger.new) {units.add(new Business_units__c
(name = o.Headquarter_company_name__c));}
insert units;

}
}

 

After insert Organization__c record

force say

 

 

Error: Invalid Data.
Review all error messages below to correct your data.
Apex trigger CloudBudget.headqarterCreate caused an unexpected exception, contact your administrator: CloudBudget.headqarterCreate: execution of AfterInsert caused by: System.DmlException: Insert failed. First exception on row 0; first error: REQUIRED_FIELD_MISSING, Required fields are missing: [CloudBudget__Organization__c]: [CloudBudget__Organization__c]: Trigger.CloudBudget.headqarterCreate: line 5, column 7

 

 

 

???

Message Edited by split on 01-06-2010 06:20 AM
  • January 06, 2010
  • Like
  • 0

Hi,

 

I have a VF page in which i have Apex input text controls and a command Button control.

I am able to fill the Text boxes using the properties created in the controller.

 

My requirement here is when clicked on the command button in the Vf page i want to dynamically add a input text to the VF page.

 

Can we do it using Apex code??.

 

I have been looking around for adding controls in VF page using Apex code. I went through the developers guide and cook book for reference even then i failed to get the result.

 

Do any one have an idea about adding apex controls dynamically??

Please help me out...This might be a very silly question to ask but i am not able to resolve this problem from days.

 

Thanks in Advance,

pspl