• ipsita.biswas@in.v2solutions.com
  • NEWBIE
  • 125 Points
  • Member since 2008

  • Chatter
    Feed
  • 5
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 0
    Questions
  • 29
    Replies

Hi,

 

i have an object called agreement which has a look up with Opportunity.

Also, on agreement i have a custom field called status__c.

 

Whenever the status values changes, i want to send an email to the opportunity owner.

 

The trigger below is raising an error:

 

Error: Invalid Data. 
Review all error messages below to correct your data.
Apex trigger sendEmail caused an unexpected exception, contact your administrator: sendEmail: execution of AfterUpdate caused by: System.EmailException: SendEmail failed. First exception on row 0; first error: INVALID_SAVE_AS_ACTIVITY_FLAG, saveAsActivity must be false when sending mail to users.: []: 

 

trigger sendEmail on echosign_dev1__SIGN_Agreement__c (after Update) {

    List<Id> agrmntId=New List<Id>();
    Id opptyowner=Trigger.New[0].echosign_dev1__Opportunity__r.OwnerId;
    
    for(echosign_dev1__SIGN_Agreement__c agrmnt:Trigger.New){
    
        if(agrmnt.echosign_dev1__Status__c=='Signed')
            agrmntId.add(agrmnt.Id);
    }
    
    List<echosign_dev1__SIGN_Agreement__c> agrmt=[Select echosign_dev1__Opportunity__r.OwnerId From echosign_dev1__SIGN_Agreement__c Where Id IN: agrmntId];
    
    for( echosign_dev1__SIGN_Agreement__c agr: agrmt){
        Messaging.SingleEmailMessage mail = new Messaging.SingleEmailMessage();
        mail.setTargetObjectId(agr.echosign_dev1__Opportunity__r.OwnerId);
        mail.setTemplateId('00X600000011PoF');
        Messaging.sendEmail(new Messaging.SingleEmailMessage[] { mail });
    }
    
}

 

Any help on this is highly appreciated.

 

Thanks,

Sales4ce

 

Hi All

I want to build a criteria on the basis of search fields and then want to use this criteria in search method query .

 

 

  public String buildCriteria(){
    
        String crt = null ;
         customerName = Prospects.customer_name__c;
           if(customerName != null && customerName !='' )
               crt = ' customer_name__c like \'+customerName+\'';

           if(prospectRefNo != null && prospectRefNo != '')
               if(crt != null)
                    crt += ' and name = \'+prospectRefNo+\'' ;
                else
                    crt = ' name = \'+prospectRefNo+\'' ;
            
            
        return crt;
    }

 

 

These lines are in search method which call buildCriteria first and then execute the code

if(criteria != null )
                prospectsList = Database.query('select  name,customer_name__c,type_of_relationship__c,'+
               'prospect_source__c,e_mail__c from  prospects__c where ' + criteria);

 

But when I try to search Prospects i got an exception or the i dont get expected result..

 

 

 

Hi,

My goal is this: In a custom Case layout, when a user clicks on an image, a lookup window shows up and the user can select one of the items displayed in it. These items have a child releationship with the Case object. Upon selection, the lookup window closes and a record is inserted. The record contains the CaseID and the childID that is assigned to the item selected in the lookup window.

To achieve this, I am using 2 vfpages, one of them contains the image that will be displayed in the Case layout. The other is my lookup page.

Here's the code of my "image" vfpage:

<apex:page StandardController="Case" extensions="RWW_Case_PunchClock_Controller" id="myApexPageId">
   
    <apex:form >             
        <apex:actionFunction name="punchIn" action="{!punchIn}" rerender="myApexPageId">
           <apex:param name="vCaseChargeTypeId" assignTo="{!oCaseChargeTypeId}" value=""/>
        </apex:actionFunction>
        <img id="imgClockPunch" src="{!$Resource.PunchIn}" onclick="javascript&colon; openLookup()"/>
    </apex:form>
   
    <script language = "javascript">
         var win;   
       
        function openLookup()
        {
            win = window.open('/apex/rww_case_charge_type_lookup', 'Select a charge type', 'height=500, width=300');
            win.focus();
        }
       
        function setSelectedChargeType(myVal)
        {           
            vCaseChargeTypeId = myVal;
            punchIn();
            win.close();
        }      
     
    </script>
</apex:page>

Here's my Image Controller code:

public class RWW_Case_PunchClock_Controller
{
    public string oCaseId {get; private set; }
    public string oCaseChargeTypeId { get; set; }   
       
    public RWW_Case_PunchClock_Controller(ApexPages.StandardController controller)
    {
        Case objCase = (Case)controller.getRecord();
        oCaseId = objCase.Id;        
    }

    public RWW_Case_PunchClock_Controller()
    {       
    }
    
    public PageReference punchIn()
    {
        Case_Charge_Type__c[] objChargeType = [Select id, Billable__c, Rate__c from Case_Charge_Type__c where Id =: oCaseChargeTypeId];

        Case_Time_Detail__c objTimeDetail = new Case_Time_Detail__c(Case__c = oCaseId, Billable__c = objChargeType[0].Billable__c,Rate__c = objChargeType[0].Rate__c,
                                                                    Start_Date__c = DateTime.Now(), Case_Charge_Type__c = objChargeType[0].Id);
        insert objTimeDetail;
        oPunchState = '';
        return null;
    }    
}



Here's my "lookup" vfpage code:

<apex:page Controller="RWW_Case_Charge_Type_Controller" showHeader="false" id="fullPage">
    <apex:form >
        <apex:pageBlock >
            <apex:pageBlockTable value="{!ChargeTypes}" var="items">
                    <apex:column headerValue="Charge Type Name" >
                        <apex:commandLink value="{!items.Name}" action="{!setId}" >
                            <apex:param name="selectedChargeTypeId" assignTo="{!selectedId}" value="{!items.Id}" />
                        </apex:commandLink>
                    </apex:column>
            </apex:pageBlockTable>
        </apex:pageBlock>
    </apex:form>
    <script language="javascript">
        function SendValueToParent()
        {                    
            window.top.opener.setSelectedChargeType("{!selectedId}");
            close();
        }
       
        if("{!selectedId}" != null && "{!selectedId}" != "")
        {
            SendValueToParent();
        }
    </script>
</apex:page>

Here's my Lookup Controller code:

public class RWW_Case_Charge_Type_Controller
{
    public List<Case_Charge_Type__c> ChargeTypes { public get; private set; }
    public string selectedId{ get; set; }
    
    public RWW_Case_Charge_Type_Controller()
    {
        ChargeTypes = [Select id, name from Case_Charge_Type__c];
    }
    
    public PageReference setId()
    {
    selectedId = ApexPages.currentPage().getParameters().get('selectedChargeTypeId');
    return null;
    }
}


The selected id is retrieved succesfully from my image vfpage. My problem is that even if I assign its value to my javascript-controller variable, the value is not given properly to the controller when invoking my punchIn method. In fact, the controller is not receiving the value at all, like it was never set.

I also tried to use a static variable inside a global class to pass my selectedChildId from my lookup controller to my "image controller". But again, the static variable is not set according to my Image controller.

Also, I am using a custom lookup page instead of invoking the built-in javascript method "openLookup" because in the future, I intend to add some validations/code to the onClose/onOpen event of the lookup page.

My question: Do you know why my selected "Child Id" is not being passed to my imageController once I have retrieved it in my vfpage ?

Thanks for reading my post

  • September 27, 2010
  • Like
  • 0

Hello,

 

I have a search function for Articles in order-positions realized in visualforce. I managed showing the search results and getting checkboxes for each result. But now I am struggling how to tell the controller which articles are selected. Her is the piece of the visualforce page and the getter and settermethods:

 

    <apex:pageBlockTable value="{!results}" var="l"
       rendered="{!NOT(ISNULL(results))}">
     <apex:column headerValue="Auswahl">
      <apex:selectCheckboxes value="{!selArt}">
       <apex:selectOptions value="{!selart}"/>
      </apex:selectcheckboxes><br/>
     </apex:column>
     <apex:column value="{!l.name}"/>
     <apex:column value="{!l.v_art_PZN__c}"/>
     <apex:column value="{!l.v_art_Hm_Positionsnr_1__c}"/>
    </apex:pageBlockTable>

 

And the contorller methods:

 

    public void setselArt (ID artID)
    {  
        system.debug ('selektierter Artikel ' + selArt );
        system.debug ('bekommener Artikel' + artID);
    }

    public Artikel__c getselArt()
    {
        system.debug ('selektierter Artikel ' + selArt );
        return selArt ;
    }

 

What can I do to get the selected article and send it to the calling page for orderpositions and setting it in the lookup-field article?

 

Thanks for your help!

 

Harry

  • September 23, 2010
  • Like
  • 0

Hi All,

 

I have created a visualforce page consisting of four fields A, B, C and D.

I'm accessing this page from Accounts and Opportunities.

 

What I require is :

When i'll access this page from Accounts the field 'C' should become read only and the field 'D' should be Hidden.

But when i'll access this page from Opportunities all the fields should be editable and visible

 

any help regarding this will be appreciated.

 

Thanks in Advance.

  • September 22, 2010
  • Like
  • 0

Hi guys,

The title pretty much explains what I need to do.

To clarify more:

I have a component with code like:

<apex:component access="global">
    <apex:attribute access="global" name="RecipientLabel" description="Recipient label." type="String" required="true"/>

-------SOME MORE STUFF HERE------

  <apex:outputPanel rendered="{!RecipientLabel}.length()>0"><div> <apex:outputLabel >{!RecipientLabel}:</apex:outputLabel> </div> </apex:outputPanel>

-----SOME MORE STUFF HERE -----


</apex:component>

If you look at the expression that I hae for rendered: "{!RecipientLabel}.length()>0"

That does not work it seems to be always false even though when I remove it the component shows and I can see that the output label has text in it.

Please let me know hwo to make that work.

I have tried sever different things like putting a javascript function in rendered different syntaxes but so I am not lucky enough to hit the right combination.

 

Thanks,

Kos

Hi,

 

I have written the following code and the tabs are not switching.

 

 

<apex:page id="AdminReportPage" standardController="Account" showHeader="true">
    <style>
    .activeTab {background-color: #236FBD; color:white; background-image:none}
    .inactiveTab { background-color: lightgrey; color:black; background-image:none}
    </style>
    <apex:tabPanel switchType="client" selectedTab="buyerIdentificationAdmin" id="theTabPanel" tabClass='activeTab' inactiveTabClass='inactiveTab'>
        <apex:tab label="Data Quality Admin" name="dataQualityAdmin" id="tabOne">
            <c:admindataqualitycomponent></c:admindataqualitycomponent>
        </apex:tab>
        <apex:tab label="Buyer Identification Admin" name="buyerIdentificationAdmin" id="tabTwo">
            <c:adminbuyeridentificationcomponent></c:adminbuyeridentificationcomponent>
        </apex:tab>
    </apex:tabPanel>
</apex:page>

 

 

 

Any help will be appreciated

 

Thanks

 

Praz

  • October 27, 2010
  • Like
  • 0

Hi,

 

i have an object called agreement which has a look up with Opportunity.

Also, on agreement i have a custom field called status__c.

 

Whenever the status values changes, i want to send an email to the opportunity owner.

 

The trigger below is raising an error:

 

Error: Invalid Data. 
Review all error messages below to correct your data.
Apex trigger sendEmail caused an unexpected exception, contact your administrator: sendEmail: execution of AfterUpdate caused by: System.EmailException: SendEmail failed. First exception on row 0; first error: INVALID_SAVE_AS_ACTIVITY_FLAG, saveAsActivity must be false when sending mail to users.: []: 

 

trigger sendEmail on echosign_dev1__SIGN_Agreement__c (after Update) {

    List<Id> agrmntId=New List<Id>();
    Id opptyowner=Trigger.New[0].echosign_dev1__Opportunity__r.OwnerId;
    
    for(echosign_dev1__SIGN_Agreement__c agrmnt:Trigger.New){
    
        if(agrmnt.echosign_dev1__Status__c=='Signed')
            agrmntId.add(agrmnt.Id);
    }
    
    List<echosign_dev1__SIGN_Agreement__c> agrmt=[Select echosign_dev1__Opportunity__r.OwnerId From echosign_dev1__SIGN_Agreement__c Where Id IN: agrmntId];
    
    for( echosign_dev1__SIGN_Agreement__c agr: agrmt){
        Messaging.SingleEmailMessage mail = new Messaging.SingleEmailMessage();
        mail.setTargetObjectId(agr.echosign_dev1__Opportunity__r.OwnerId);
        mail.setTemplateId('00X600000011PoF');
        Messaging.sendEmail(new Messaging.SingleEmailMessage[] { mail });
    }
    
}

 

Any help on this is highly appreciated.

 

Thanks,

Sales4ce

 

I am at a loss on what to do.  So we created this update trigger and it worked great in the sandbox.  Pushed it over to production with no issues.  We went through some test records and everything was great.  Then, we try to do a data load.  That's when we found out about bulk triggers. Here is our trigger.  We have a master detail relationship with Account and Program (client__c housing the account id).  Then Program has a master detail relationship with Reward (rm_detail_link__c housing the program id).  Any help would be great.  I've been reading on the maps, but am not quite sure how to do the maps since we need to access 4 objects - User, Account, Program and Reward.  Thanks!

 

trigger RMrewardupdate on Reward__c (before update) {
    for(Reward__c rs: trigger.new){
        ID pID = [select RM_Detail_Link__c from Reward__c where id = :rs.id].rm_detail_link__C;
        ID aID = [select client__c from program__c where id = :pid].client__c;
        ID rmID = [select relationship_manager__c from account where id = :aid].relationship_manager__C;
        
        If (rmID  != null) {
            string RMemail = [select email from user where id = :rmid].email;
            rs.rm_user_id__c = rmID;
            rs.rm_email__c = RMemail;
            
            ID rrmID = [select managerid from user where id = :rmid].managerid;
    
            If (rrmID  != null) {
                string RRMemail = [select email from user where id = :rrmid].email;
                rs.rrm_email__c = RRMemail;
            }
        }
    }
}

Hi All,

 

Cannot figure out why this would be causing the classic "Too many SQL Queries" error. As far as I know I have implemented what is  best-practice for bulk processing.

 

However when insert tasks using data loader, it's generating the error above.

 

Any help pointers appreciated - thanks

 

 

trigger CloseOriginalTask on Task (after insert) {

	List<Task> taskRecords = [select TaskIdFollowedUp__c from Task where Id IN:Trigger.newMap.keySet()];
	List<Task> tasksForUpdate = new List<Task>{};
	
	if (taskRecords.size()!=0){
	
	for (Task taskRecord : taskRecords){
		
		Id taskId = taskRecord.TaskIdFollowedUp__c;
		List<Task> originalTask = [select Id, Status from Task where Id=:taskId];
		
			for (Task t:originalTask){
					t.Status = 'Completed';	
					tasksForUpdate.add(t);	
			}
		
			
	}
		
	
	update tasksForUpdate;
	
	}

}

 

 

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 everyone,

 

I am facing a strange issue with an SOSL in my apex code.

My SOSL searches against a custom object called Keyword.

 

One of my keyword record has the value " Ivan systems,Mobile Systems,Solution Provider" in one of its long text area(32000) field.

 

String keywordTerm =null;
keywordTerm = 'Mobile*';
Set<Id> validAccountsSetNonFed = new Set<Id>();
validAccountsSetNonFed.add('0013000000AP7Hs');
List<List<SObject>> searchList=[FIND :keywordTerm in all fields returning Keyword__c(Account__c where Account__c IN :validAccountsSetNonFed limit 200)];
List<Keyword__c> accountsWithKeyWord = searchList[0];
System.debug('##########################:'+accountsWithKeyWord);

 

This SOSL returns 0 rows if i give the keywordTerm as 'Mobile*'.

But when i give it as 'Mobile* and *ivan*' it fetches me the record.

 

What could be the reason that this code snippet is behaving in this way.?

 

 

Thanks & Regards,

Vineetha

i have 1 drop down list , i have generated months according to billing entries

vat i want is when i click on the month in drop down list it has to Generate next 6 mnths including present mnth

anyone pllllz help me

txs in advancee..........

 

I have created a dependent objects  drop down lists of type product and item in the visualforce page .
I need to create a command button in which the action is to generate 5 rows in the visualforce page , each row contains same  dependent object drop down list which i have created earlier .

I have generated rows using repeater controller and wrapper class but, the problem is that only last row drop down list works remaining rows remain inactive .
Can any one help me on this issue???

Please see the following code:

 

apex class:

 

public class dependentObjects{

String product;

String item;
String name;
String accname;
String divname;
String startperiod;


   public List<WrapperQueAns> lstQueAns = new List<WrapperQueAns>{};

 public List<WrapperQueAns> propLstQuesAns { get { return lstQueAns; } set { lstQueAns = value; } }


public String getProduct()
{
return this.product;
}
public void setProduct(String s)
{
this.product=s;
}
public String getAccname()
{
return this.accname;
}
public void setAccname(String s)
{
this.accname=s;
}
public String getItem()
{
return this.item;
}
public void setItem(String s)
{
this.item=s;
}
public String getDivname()
{
return this.divname;
}
public void setDivname(String s)
{
this.divname=s;
}

public String getName()
{
return this.name;
}
public void setName(String s)
{
this.name=product;
}

public String getStartperiod()
{
return this.startperiod;
}
public void setStartperiod(String s)
{
this.startperiod=s;
}


 

public List<SelectOption> getProducts(){

List<SelectOption> optionList=new List<SelectOption>();
optionList.add(new SelectOption('','-NONE-'));

for(product__c bp:[select name from product__c order by Name])
{
optionList.add(new SelectOption(bp.id,bp.name));
}
return optionList;
}
public List<SelectOption> getItems() {
      List<SelectOption> optionList = new List<SelectOption>();
     
       optionList.add(new SelectOption('', '- None -'));

   
      if(product!= NULL) {

      
        for (item__c bi : [select name from item__c bi where bi.product__c = :product]){
          optionList.add(new SelectOption(bi.id,bi.name));
        }
      }
      return optionList;
    }
   
    public List<SelectOption> getAccountname()
    {
     List<SelectOption> optionList = new List<SelectOption>();
     optionList.add(new SelectOption('', '- None -'));
     for(Account ac:[select name from Account where type='Client'])
{
optionList.add(new SelectOption(ac.id,ac.name));
}
return optionList;
   
    }
   
    public List<SelectOption> getDivnames(){

List<SelectOption> optionList=new List<SelectOption>();
optionList.add(new SelectOption('','-NONE-'));

for(Division__c di:[select name from Division__c ])
{
optionList.add(new SelectOption(di.id,di.name));
}
return optionList;
}

    public List<SelectOption> getStartp(){

List<SelectOption> optionList=new List<SelectOption>();
optionList.add(new SelectOption('','-NONE-'));

for(Billing_period__c sp:[select name from Billing_period__c ])
{
optionList.add(new SelectOption(sp.id,sp.name));
}
return optionList;
}

public void DynamicRow(){

for(Integer i=0;i<5;i++){

WrapperQueAns wqa = new WrapperQueAns();

wqa.propAns    = '';
 
lstQueAns.add(wqa);

 }

}
  public class WrapperQueAns{public String propAns   { get; set; } }//End Class WrapperQueAns
 
}

 

visualforce page:


<apex:page controller="dependentObjects" >
<apex:form >

<p>
<table>
<tr>
<td>

Account:
<apex:selectList value="{!accname}" size="1" id="accname">
            <apex:selectOptions value="{!Accountname}"/>  
          </apex:selectList>

</td>
<td>
Division:
<apex:selectList value="{!divname}" size="1" id="division">
            <apex:selectOptions value="{!divnames}"/>
          </apex:selectList>

</td>
<td>
Start Period:
<apex:selectList value="{!startperiod}" size="1" id="startp">
            <apex:selectOptions value="{!startp}"/>
            
          </apex:selectList>

</td>
</tr>
<tr>
<td>
product
<apex:selectList value="{!product}" size="1" id="category2">
            <apex:selectOptions value="{!products}"/>
            <apex:actionSupport event="onchange" rerender="features2,test,r"/>
          </apex:selectList>
          </td>
          <td>
Item     
     <apex:selectList value="{!item}" size="1" id="features2" disabled="{!ISNULL(product)}">
         <apex:selectOptions value="{!items}"/>
     </apex:selectList>
     <apex:inputText value="{!name}" id="test"/>
</td>

<td>
              Sep10  
                <input name="sum" value="{!name}" size="5" id="r" type="text"/>
               
</td>

<td>                
           Oct10     
                <input name="sum" value="2" size="5" type="text"/>
                </td>
              
                <td>
                  Nov10
                <input name="sum" value="1" size="5" type="text"/>
                </td>
              
                <td>
                  Dec10
                <input name="sum" value="0" size="5" type="text"/>
                </td>
                
                <td>
                Total:
                &nbsp;&nbsp;
                
                
                <input name="totalSum" id="totalSum" value="6" size="2" readonly="readonly" type="text"/>
               </td>
              </tr>
              </table>  
              </p>
                
                  
            
</apex:form>

<apex:outputPanel id="refreshdata">
<apex:repeat value="{!propLstQuesAns}" var="varLQA" id="textquesrp">
<apex:form >

 <p>

product
<apex:selectList value="{!product}" size="1" id="category2">
            <apex:selectOptions value="{!products}"/>
            <apex:actionSupport event="onchange" rerender="features2,test"/>
          </apex:selectList>
          
Item     
     <apex:selectList value="{!item}" size="1" id="features2" disabled="{!ISNULL(product)}">
         <apex:selectOptions value="{!items}"/>
     </apex:selectList>
     <apex:inputText value="{!name}" id="test"/>

 </p>

</apex:form>
</apex:repeat>
</apex:outputPanel>
<apex:form >
<apex:commandButton action="{!DynamicRow}" reRender="refreshdata" value="ADD ROW"/>
</apex:form>

</apex:page>

Hi All

I want to build a criteria on the basis of search fields and then want to use this criteria in search method query .

 

 

  public String buildCriteria(){
    
        String crt = null ;
         customerName = Prospects.customer_name__c;
           if(customerName != null && customerName !='' )
               crt = ' customer_name__c like \'+customerName+\'';

           if(prospectRefNo != null && prospectRefNo != '')
               if(crt != null)
                    crt += ' and name = \'+prospectRefNo+\'' ;
                else
                    crt = ' name = \'+prospectRefNo+\'' ;
            
            
        return crt;
    }

 

 

These lines are in search method which call buildCriteria first and then execute the code

if(criteria != null )
                prospectsList = Database.query('select  name,customer_name__c,type_of_relationship__c,'+
               'prospect_source__c,e_mail__c from  prospects__c where ' + criteria);

 

But when I try to search Prospects i got an exception or the i dont get expected result..

 

 

 

I have 2 custom object Prospect and CallMemo . CallMemo has an lookup field Prospect Ref No . now when I want to save a call Memo With a Prospect How can I put a correct value in callmemo's prospect ref no . I tried to assign prospect Id to prospect Ref no . But i got an exception .

 

public PageReference save(){
        callMemo.prospect_ref_no__c = selectedProspect.id;
        insert callMemo;

       return null;

}

 

callMemo and selectedProspect are instances of Call_Memo__c and Prospects__c respectively .

 

plzzzzzzz help...

Can We rerender the the above mentioned component through ajax ?

I found a No in visualforce tutorials . I need to refresh the content of a pageblocktable .

is there any way to refresh pageblockcomponent .

 

thanks in advance.........

 

 

Hey all,

 

I'm having a problem with what is probably a very simple solution, but I just can't wrap my head around it.  

I'm trying to update an Account.Type field with a set value when an Opportunity hits a certain Stage, but only if an Account is a specific type already. 

 

Here's the code:

trigger SetAccountToP on Opportunity (before insert, before update) {
    
   for(Opportunity o : Trigger.New){
        if((o.StageName == 'Proposal/Price Quote' || o.StageName == 'Negotiation/Review' || o.StageName == 'Closed Won') && o.Account.Type == 'User')
        {   Account a = o.account;
            a.Type = 'Prospect';
            update a;  
         }   
    }
}

 

 

I know this code is pretty bad, but I've tried many things and this is the easiest to read through to illustrate my point.


Any help would be appreciated.

In opportunity object having an standard related list "products".And another custom related list am using is "Accomodation ".

In Products related list ,if am adding products using add product button same products will be added into custom related list  "Accomodation" also at the same time.

so my trigger in OpportunityLineItem is

 

trigger accc on OpportunityLineItem (before insert,after insert) {
List<Accomodation__c> lstAccomodation = new List<Accomodation__c>();
    OpportunityLineItem  to=trigger.new[0];

   Opportunity q=[select id from Opportunity where id=:to.Opportunity__c];
    list<OpportunityLineItem> ql=[select id,ListPrice,PriceBookEntry.Product2.Family,PriceBookEntry.Name,PriceBookEntry.Product2Id ,Subtotal,TotalPrice from OpportunityLineItem where OpportunityId=:q.id];

    for(OpportunityLineItem qli:ql){
        Accomodation__c lm=new Accomodation__c();
        lm.Price__c=qli.ListPrice;
       
        lm.Name=qli.PriceBookEntry.Name;
        lm.OpportunityLineItem__c=to.id;
        lstAccomodation.add(lm);
      
    }
    if(lstAccomodation != null && !lstAccomodation.isEmpty()){
        insert lstAccomodation;
    }
}

 

In this line lm.OpportunityLineItem__c=to.id; am having error

Error: Compile Error: Invalid field OpportunityLineItem__c for SObject Accomodation__c at line 13 column 9 

because Accomodation object&nbsp;need an lookup relationship to OpportunityLineItem.</script>

but there is no lookup relationship to OpportunityLineItem

 How to solve it

 

In need of Javascript Advice

We need some Javascript help, so I thought I'd post this question here and on developerforce:

We are in the process of developing a public facing site that exposes some input fields from a custom object and allows the guest user to edit those fields. The business requirement is to provide a check box that says something to the effect of "check this box if you want to keep all your information the same", and if the box is checked, the UI will lock the input fields from being edited. We cannot figure out the javascript that will make this happen. We've tried “rendered”, “disabled”, and “hidden” to try and collapse/hide the outputpanel, etc, etc. Here is the code thus far (I've highlighted the section that is causing trouble using red font):

<apex:page standardController="ION_LPP_Account_Detail__c" extensions="LPPdetail" showHeader="false" sidebar="false">
<apex:includeScript value="{!$Resource.jquery}"/>
<head>
<script>
function changeFont(input, textid) {
var x=document.getElementById(textid);
if(input.checked) { x.rendered = (input.checked); x.hide = (input.checked); x.style.fontWeight = "bold"; }
else { x.disabled = (input.checked); x.style.fontWeight = "normal"; }
}
</script>
</head>
<apex:form >


<!-- The first outputPanel calls the function, passing in the existing occurance of the checkbox, as well as the DOM ID of the output component. -->


<apex:outputPanel layout="block">
<label for="checkbox">Click this box to collapse fields below: </label>
<input id="checkbox" type="checkbox"
onclick="changeFont(this,'{!$Component.thePanel}');"/>
</apex:outputPanel>

<!-- The second outputPanel contains the text that will be changed. -->


<apex:outputPanel id="thePanel" layout="block">
Physician:<apex:inputField id="sp" value="{!ION_LPP_Account_Detail__c.OG_Secondary_Physician__c}"/>
</apex:outputPanel>
</apex:form>
</apex:page>

If anyone has any ideas they would be greatly welcomed! Thanks!