• prabhutum
  • NEWBIE
  • 50 Points
  • Member since 2009

  • Chatter
    Feed
  • 2
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 8
    Questions
  • 16
    Replies

I wrote a trigger after update for child cases. If all the child cases are closed, the Inactive field of the ContactId reference of the parent case will be set to true...I am getting an exception with the following code, when I try to close the last child case. Its then trying to evaluate the innermost if condition and hitting the exception..

trigger childsClosed on Case (after update) { Case b = new Case(); if (Trigger.New[0].Status == 'Closed') { if (Trigger.New[0].ParentId != null) { list<Case> a = [Select Id from Case where Id = :Trigger.New[0].ParentId and Subject = 'Delete Network ID or Reset password' limit 1]; if(a.size() != 0) { b = a[0];} if (b.Id != null) { integer childCases = [Select count() from Case where ParentId = :b.Id]; integer closed = [Select count() from Case where ParentId = :b.id and Status = 'Closed']; if (closed == childCases) { b.Contact.Inactive__c = true; } } } } }

And I am getting the exception that says:

 

Apex script unhandled trigger exception by user/organization: 005700000018KNh/00D70000000JLCa

 

childsClosed: execution of AfterUpdate

 

caused by: System.SObjectException: SObject row was retrieved via SOQL without querying the requested field: Case.Contact

 

Trigger.childsClosed: line 12, column 6

 

Hello,

 

I am a newbie to Visual Force. To meet a requirement I have to dynamically change the field header/labels of datatable based on certain values in the Controller.

 

Could someone please tell me how it can be done? Any code snippet or link to code sample would be appreciated!

 

Thanks!

Pr@sh...

All -

 

I am new to VF and not sure what is possible and what is not.

 

Background: The way we architectured our data model is that a contact could be associated to multiple accounts. So we exteneded standard master-child relationship between Account and Contact to master-child-grandchild for Account-Contact-AccountsSupported. The accountsSupported custom object stores multiple accounts suported by a contact.

 

Issue: On a new Case page we have Account Lookup icon -- Can that be programmed to call a new vf page which would retrieve data from AccountSupported instead of Account object? Or can the Account Looup page be overriden with custom VF page somehow? If not, how would I go about this situation?

 

 

Any ideas are welcome!

 

Thanks!

Pr@sh...

 

Message Edited by prabhutum on 08-10-2009 05:44 AM

Experts:

 

Does anyone know how to make custom link referring to local network drive work with Firefox? I played around for a bit but could not figure it out.

 

The link works fine with IE, but with Firefox its trying to open the link as web address. I tried to open it as plain URL as well as JavaScript with no success.

 

The local network drive looks something like below,

 

URL 

"\\lvlhome\\common\\DeltaMetrics"

 

 

In JavaSript

{!REQUIRESCRIPT("/soap/ajax/16.0/connection.js")}

window.location.pathname="file:\\\\\lvlhome\\common\\DeltaMetrics";

 

 

Let me know if there is a way to make this work in FireFox.

 

Thanks!

Pr@sh...

 

 

Experts,

 

I have a situation where based on where the Update is executed from, I got to decide on whether to execute or bypass the trigger. In conventional programming languages, I would have accomplished this by a context or an instance variable.

 

I am relatively new to Apex and could not get my head around on the best way to achieve this. Any ideas are welcome!

 

Thanks!

Pr@sh...

 

Hello,

 

When I try to initialize the AJAX toolkit in javascript of a visual force page, I get error, "Function REQUIRESCRIPT may not be used in this type of formula." What am I doing wrong?

 

<script language="javascript">

  {!requireScript("/soap/ajax/14.0/connection.js")};

  {!requireScript("/soap/ajax/14.0/apex.js")};

 

  function openOBPPopUp(){ 

        var retVal = sforce.apex.execute("OBP_WebService_Wrapper","call_OBP_WS",{serverURL:"{!$Api.Enterprise_Server_URL_140}"});

  }

</script>

 

Thanks!

Pr@sh...

 

 

Message Edited by prabhutum on 05-20-2009 12:14 PM

Hello,

 

I am trying to deploy some VF controller which has 89% of coverage.. The VF page runs fine on sandbox when I try to deploy the controller get blunt message "An error occurred on your page."

 

Has anyone seen the error before and have an idea of what could be wrong?

 

Thanks!

Pr@sh...

 

I created an Opportunity extension class and page, which retrieves related Deals. I could add this page to the Opportunity page layout but not as a related list.

 

Is there a limitation that the VF page can not be added to the related list or it's the way I defined the page? I am new to VF and pointers or useful code snippet will be appreciated.

 

Thanks!

Pr@sh...

 

Message Edited by prabhutum on 04-27-2009 07:13 AM

Fellas-

 

First of all, this is my first VF page and I am new to web development. So the answer to what I am looking for could potentially be simple...

 

As I have many columns in my dataTable, the whole page gets stretched. How do I split the contents of record on two rows in VF?

 

Suppose, I have 6 fields, A, B, C, D, E and F. I want to display A, B and C on the first row, and D, E and F on the second row.

 

 

Field-A Field-B Field-C

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

    Field-D Field-E Field-F

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

rec1-A rec1-B rec1-C

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

    rec1-D rec1-E rec1-F

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

rec2-A rec2-B rec2-C

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

    rec2-D rec2-E rec2-F

....
and so on...

 

 

Your response will be greatly appreciated!

 

cheers,

Pr@sh...

Hello,

 

I am a newbie to Visual Force. To meet a requirement I have to dynamically change the field header/labels of datatable based on certain values in the Controller.

 

Could someone please tell me how it can be done? Any code snippet or link to code sample would be appreciated!

 

Thanks!

Pr@sh...

Experts:

 

Does anyone know how to make custom link referring to local network drive work with Firefox? I played around for a bit but could not figure it out.

 

The link works fine with IE, but with Firefox its trying to open the link as web address. I tried to open it as plain URL as well as JavaScript with no success.

 

The local network drive looks something like below,

 

URL 

"\\lvlhome\\common\\DeltaMetrics"

 

 

In JavaSript

{!REQUIRESCRIPT("/soap/ajax/16.0/connection.js")}

window.location.pathname="file:\\\\\lvlhome\\common\\DeltaMetrics";

 

 

Let me know if there is a way to make this work in FireFox.

 

Thanks!

Pr@sh...

 

 

Hello - I am working on the Developer Guide project and exercises and I'm not able to see one of the custom objects that I created which is housing data.  The project calls for building a custom application, the Recruiting App, for Universal Containers (the fictitious company).  There are 3 related objects that are the subject of my problems.  The Job Application object is a custom object that is a junction object between the Candidate and Position objects, which are Master Objects for the Job Application object.  Though I can see all of the object information for Job Application object through the Setup menu, it does not show up at all in the Apex Explorer or Force.com IDE Schema viewer.  I use the Apex Explorer and the Eclipse Force.com IDE to build and test SOQL queries and find fields and relationships I need to access in Apex Classes.  Is there some setting that some how got set to hide this information?  OR does anyone have any idea how I can resolve it? 

 

Additional information... I have followed the Load Instructions from the Code Share for this project for every chapter, which involves running an Ant Based Force.com Migration tool to load files and packages into the Force.com application before every chapter.  I found and fixed several unpublished errors with this Code Share project.  It seems to function fine in every other way, except I cannot see the Job Application relationship and fields from the Candidate and Position objects. Any help is greatly appreciated. Thanks,SCR

 

Message Edited by SCR on 07-25-2009 07:55 PM
Message Edited by SCR on 07-25-2009 07:57 PM
  • July 26, 2009
  • Like
  • 0

I have a visual force page that is calling an external web service and whenever I invoke the method on the web service I get this error. I tested the web service outside of salesforce and it works fine. In addition I made a hello world method and it runs find in salesforce. It just whenever I try to run any other method that does more than a simple hello world I get this error. Any help would be greatly appreciated. 

 

 

System.CalloutException: Web service callout failed: WebService returned a SOAP Fault: Server was unable to read request. ---> There is an error in XML document (1, 814). ---> Input string was not in a correct format. faultcode=soap:Client faultactor=

  • July 24, 2009
  • Like
  • 0

Experts,

 

I have a situation where based on where the Update is executed from, I got to decide on whether to execute or bypass the trigger. In conventional programming languages, I would have accomplished this by a context or an instance variable.

 

I am relatively new to Apex and could not get my head around on the best way to achieve this. Any ideas are welcome!

 

Thanks!

Pr@sh...

 

I wrote a trigger after update for child cases. If all the child cases are closed, the Inactive field of the ContactId reference of the parent case will be set to true...I am getting an exception with the following code, when I try to close the last child case. Its then trying to evaluate the innermost if condition and hitting the exception..

trigger childsClosed on Case (after update) { Case b = new Case(); if (Trigger.New[0].Status == 'Closed') { if (Trigger.New[0].ParentId != null) { list<Case> a = [Select Id from Case where Id = :Trigger.New[0].ParentId and Subject = 'Delete Network ID or Reset password' limit 1]; if(a.size() != 0) { b = a[0];} if (b.Id != null) { integer childCases = [Select count() from Case where ParentId = :b.Id]; integer closed = [Select count() from Case where ParentId = :b.id and Status = 'Closed']; if (closed == childCases) { b.Contact.Inactive__c = true; } } } } }

And I am getting the exception that says:

 

Apex script unhandled trigger exception by user/organization: 005700000018KNh/00D70000000JLCa

 

childsClosed: execution of AfterUpdate

 

caused by: System.SObjectException: SObject row was retrieved via SOQL without querying the requested field: Case.Contact

 

Trigger.childsClosed: line 12, column 6

 

Could somebody help me with this problem? I'm trying to Split an EmailCc values into separate email fields but I get the above error when I try and deploy this trigger to my production server.

 

 

 

trigger Acceleration_EmailCCSplit on Case (before insert, before update) {

    Map<String, Case> CaseMap = new Map<String,Case>();    Map<String,

Case> CaseMapOld = new Map<String,Case>();    Map<String, String> CaseMapOldNew = new Map<String,String>();

 

 

     for (Case casedata : System.Trigger.new)

   {

         if (casedata.EmailCC__c!=null) {

               System.debug('# EmailCC Outside 1.1 EmailCC__c ' + casedata.EmailCC__c);

            if (System.Trigger.isInsert) {              System.debug('# EmailCC Outside 1.2 System.Trigger.isInsert ' + System.Trigger.isInsert);

               CaseMap.put(System.Trigger.oldMap.get(casedata.id).EmailCC__c, casedata);

               CaseMapOldNew.put(casedata.EmailCC__c, casedata.EmailCC__c);

            }

                  if (System.Trigger.isUpdate) {

                       System.debug('# EmailCC Outside 1.3 System.Trigger.isUpdate ' + System.Trigger.isUpdate);

                        if (casedata.EmailCC__c != System.Trigger.oldMap.get(casedata.id).EmailCC__c){

                           System.debug('# EmailCC Outside 1.4 EmailCC is difference to previous version');                           System.debug(

'# EmailCC Outside 1.5 EmailCC Old = ' + System.Trigger.oldMap.get(casedata.id).EmailCC__c);                           System.debug('# EmailCC Outside 1.6 EmailCC New = ' + casedata.EmailCC__c );

                           CaseMap.put(System.Trigger.oldMap.get(casedata.id).EmailCC__c, casedata);

                           CaseMapOldNew.put(System.Trigger.oldMap.get(casedata.id).EmailCC__c,casedata.EmailCC__c);

                   }

              }

          }

    }

 

// List<Case> UpdateCases = new List<Case>();

 

System.debug('# EmailCC Outside 2.0 List Count ' + CaseMap.size());

System.debug('# EmailCC Outside 2.1 List keySet() ' + CaseMap.keySet());

for ( Case casedatalist : [SELECT EmailCC__c, Email_CC_1__c, Email_CC_2__c FROM Case Where EmailCC__c IN : CaseMap.keySet() ])

{

        System.debug('# EmailCC list Inside 2.2' + casedatalist.EmailCC__c);

        casedatalist.EmailCC__c = CaseMapOldNew.get(casedatalist.EmailCC__c);

        casedatalist.Email_CC_1__c = '';        casedatalist.Email_CC_2__c = '';

 

        Integer y = 0 ;

for(String s : casedatalist.EmailCC__c.Replace(',',';').Split(';')) {

y = y + 1 ;

System.debug('# EmailCC__c - s ' + y + ' :: ' + s);

if ( y == 1 ) {System.debug(

'# EmailCC__c - 1 found ' + s);

casedatalist.Email_CC_1__c = s;

} else if ( y == 2 ) {System.debug('# EmailCC__c - 2 found ' + s);

casedatalist.Email_CC_2__c = s;

}

// UpdateCases.add(casedatalist );

}

// Update UpdateCases;

 

}

}

Hey Guys,

 

I am getting an error while trying to parse a WSDL:

Error: Failed to parse wsdl: Unable to find schema for element; {http://www.w3.org/2001/XMLSchema}schema

 

 

Here is the WSDL for the Webservice:

 

<?xml version="1.0" encoding="utf-8"?>
<wsdl:definitions xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/" xmlns:tm="http://microsoft.com/wsdl/mime/textMatching/" xmlns:soapenc="http://schemas.xmlsoap.org/soap/encoding/" xmlns:mime="http://schemas.xmlsoap.org/wsdl/mime/" xmlns:tns="http://207.97.239.184" xmlns:s="http://www.w3.org/2001/XMLSchema" xmlns:soap12="http://schemas.xmlsoap.org/wsdl/soap12/" xmlns:http="http://schemas.xmlsoap.org/wsdl/http/" targetNamespace="http://207.97.239.184" xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/">
  <wsdl:types>
    <s:schema elementFormDefault="qualified" targetNamespace="http://207.97.239.184">
      <s:element name="FindCustomer">
        <s:complexType>
          <s:sequence>
            <s:element minOccurs="0" maxOccurs="1" name="CustomerID" type="s:string" />
          </s:sequence>
        </s:complexType>
      </s:element>
      <s:element name="FindCustomerResponse">
        <s:complexType>
          <s:sequence>
            <s:element minOccurs="0" maxOccurs="1" name="FindCustomerResult">
              <s:complexType>
                <s:sequence>
                  <s:element ref="s:schema" />
                  <s:any />
                </s:sequence>
              </s:complexType>
            </s:element>
          </s:sequence>
        </s:complexType>
      </s:element>
    </s:schema>
  </wsdl:types>
  <wsdl:message name="FindCustomerSoapIn">
    <wsdl:part name="parameters" element="tns:FindCustomer" />
  </wsdl:message>
  <wsdl:message name="FindCustomerSoapOut">
    <wsdl:part name="parameters" element="tns:FindCustomerResponse" />
  </wsdl:message>
  <wsdl:portType name="ServiceSoap">
    <wsdl:operation name="FindCustomer">
      <wsdl:input message="tns:FindCustomerSoapIn" />
      <wsdl:output message="tns:FindCustomerSoapOut" />
    </wsdl:operation>
  </wsdl:portType>
  <wsdl:binding name="ServiceSoap" type="tns:ServiceSoap">
    <soap:binding transport="http://schemas.xmlsoap.org/soap/http" />
    <wsdl:operation name="FindCustomer">
      <soap:operation soapAction="http://207.97.239.184/FindCustomer" style="document" />
      <wsdl:input>
        <soap:body use="literal" />
      </wsdl:input>
      <wsdl:output>
        <soap:body use="literal" />
      </wsdl:output>
    </wsdl:operation>
  </wsdl:binding>
  <wsdl:binding name="ServiceSoap12" type="tns:ServiceSoap">
    <soap12:binding transport="http://schemas.xmlsoap.org/soap/http" />
    <wsdl:operation name="FindCustomer">
      <soap12:operation soapAction="http://207.97.239.184/FindCustomer" style="document" />
      <wsdl:input>
        <soap12:body use="literal" />
      </wsdl:input>
      <wsdl:output>
        <soap12:body use="literal" />
      </wsdl:output>
    </wsdl:operation>
  </wsdl:binding>
  <wsdl:service name="Service">
    <wsdl:port name="ServiceSoap" binding="tns:ServiceSoap">
      <soap:address location="http://207.97.239.184/dummywebservice/service.asmx" />
    </wsdl:port>
    <wsdl:port name="ServiceSoap12" binding="tns:ServiceSoap12">
      <soap12:address location="http://207.97.239.184/dummywebservice/service.asmx" />
    </wsdl:port>
  </wsdl:service>
</wsdl:definitions>

 

Please assist.

 

Manny

Hello,

 

When I try to initialize the AJAX toolkit in javascript of a visual force page, I get error, "Function REQUIRESCRIPT may not be used in this type of formula." What am I doing wrong?

 

<script language="javascript">

  {!requireScript("/soap/ajax/14.0/connection.js")};

  {!requireScript("/soap/ajax/14.0/apex.js")};

 

  function openOBPPopUp(){ 

        var retVal = sforce.apex.execute("OBP_WebService_Wrapper","call_OBP_WS",{serverURL:"{!$Api.Enterprise_Server_URL_140}"});

  }

</script>

 

Thanks!

Pr@sh...

 

 

Message Edited by prabhutum on 05-20-2009 12:14 PM

I have created 2 workflow rules , both uses one single field update on a Custom "Schedule"(i am tryin to update this object once my workflow rule satisfies) object.

 

Now the problem is my workflow rules are working fine , but my schedule object isn't updating.

I have taken the concept of the cronkit scheduling and tryin to create schedule with 1 simple custom object.

Can anyone suggest if thrs any problem with workflow rules or trigger.

 

 

Trigger ->

 

trigger Schedule on Test_Workflow__c (before insert, before update) {
       
    for(Test_Workflow__c bs: Trigger.new) {
         
          if (bs.Runner__c == true) {          
                       
            Datetime nextrun = bs.Next_Run_Date__c;
            if(bs.Script_Type__c == 'Days') {
                nextrun = nextrun.addDays(Integer.valueOf(bs.Frequency__c));             
            } else if(bs.Script_Type__c == 'Hours') {        
                nextrun = nextrun.addHours(Integer.valueOf(bs.Frequency__c)); 
            } else if(bs.Script_Type__c == 'Minutes') {        
                nextrun = nextrun.addMinutes(Integer.valueOf(bs.Frequency__c)); 
            }
                       
           Test_Workflow__c newRun = new Test_Workflow__c(
                    Next_Run_Date__c = nextrun,
                    Runner__c = false,
                    Name = bs.Name,
                    Frequency__c = bs.Frequency__c,
                    Script_Type__c = bs.Script_Type__c);
            insert newRun;
              
            bs.Next_Run_Date__c = nextrun;
            bs.Runner__c = false;
           
          }else{
              if (bs.Test_Schedule__c == false) {
                        bs.Test_Schedule__c= true;
                        bs.Test_Schedule_2__c = false;
              } else {
                        bs.Test_Schedule__c = false;
                        bs.Test_Schedule_2__c = true;                       
              }
              Datetime nextrun = bs.Next_Run_Date__c;
             if(bs.Script_Type__c == 'Days') {
                 nextrun = nextrun.addDays(Integer.valueOf(bs.Frequency__c));             
             } else if(bs.Script_Type__c == 'Hours') {        
                 nextrun = nextrun.addHours(Integer.valueOf(bs.Frequency__c)); 
             } else if(bs.Script_Type__c == 'Minutes') {        
                 nextrun = nextrun.addMinutes(Integer.valueOf(bs.Frequency__c)); 
             }
             bs.Next_Run_Date__c = nextrun;
             bs.Runner__c = false;
          }
    }

}

 

My field update is  Runner__c = True;

 

 

1) 1st Workflow rule  ->  Test_Schedule__c = true

1) 2nd Workflow rule  ->  Test_Schedule_2__c = true

 

 

workflow are working fine , but the  Test_Workflow__c object is updating only once at the starting , after that its never updating , but if i am updating it manually then it works fine.Please tell me some workaround ,my trigger and schedules were working fine  , but after the new updations on the workflow rules , it seems they are not giving expected results......SFDC admins please help this out.

All --

 

This is my first time using VF and creating a controller (shocker) and I have hit a roadblock with a project I am working on.  I have a page that is executed from the opportunity that pulls the current opportuninty and account ID to display some pertinent information from the account and opportunity as well as providing a list of available product inventory.  I have built the page and controller by reviewing the docs and a ton of forum post regarding wrapper classes and the use of checkboxes in a VF form page.  I have most of the controller built but I do not understand how to pull it all together and insert the account and opp IDs into my customer inventory object.  The goal is to loop through the list of invetory items that are selected and have the current Account and Opp IDs updated in the Inventory object.  Here is the controller:

 

 

public class InventoryController { Account account; Opportunity opportunity; Inventory__c inventory; public Account getAccount() { return [select id, name, fice_code__c, resellers_name__c, type from Account where id = :ApexPages.currentPage().getParameters().get('accid')]; } public Opportunity getOpportunity() { return [select id, name, amount, type, closedate from Opportunity where id = :ApexPages.currentPage().getParameters().get('oppid')]; } public List<cInventory> inventoryList {Get; Set;} public List<cInventory> getInventory(){ if (inventoryList == null){ inventoryList = new List<cInventory>(); for(Inventory__c c : [select Id, name, inventory_type__c, status__c, MAC_Address__c, Hard_Drive_Serial__c, FPIO_serial__c, ExIO_Card_Serial_optional__c, Appliance_Ateme_Serial__c, Build_date__c, account__r.id, account__r.name from Inventory__c where status__c = 'available' and (inventory_type__c = 'sales' or inventory_type__c = 'trial') ORDER BY Build_date__c ASC limit 1000]){ inventoryList.add(new cInventory(c)); } } return inventoryList; } public PageReference processSelected(){ List<Inventory__c> selectedInventory = new List<Inventory__c>(); for(cInventory cCon : getInventory()){ if(cCon.selected == true){ selectedInventory.add(cCon.con); } } PageReference oppPage = new PageReference ('/' + ApexPages.currentPage().getParameters().get('oppid')); oppPage.setRedirect(true); return oppPage; } public class cInventory{ public Inventory__c con {get; set;} public Boolean selected {get; set;} public cInventory(Inventory__c c){ con = c; selected = false; } } }

 

 and the VF page:

 

 

<apex:page Controller="InventoryController" tabStyle="Inventory__c"> <apex:form id="theForm"> <apex:pageBlock title="Account Information"> <apex:pageBlockSection Title="Account Section"> <apex:pageBlockTable value="{!account}" var="account"> <apex:column value="{!account.id}"/> <apex:column value="{!account.Name}"/> <apex:column value="{!account.FICE_Code__c}"/> <apex:column value="{!account.Resellers_Name__c}"/> <apex:column value="{!account.type}"/> </apex:pageBlockTable> </apex:pageBlockSection> <apex:pageBlockSection title="Opportunity Section"> <apex:pageBlockTable value="{!opportunity}" var="opp"> <apex:column value="{!opp.id}"/> <apex:column value="{!opp.Name}"/> <apex:column value="{!opp.type}"/> <apex:column value="{!opp.amount}"/> <apex:column value="{!opp.closedate}"/> </apex:pageBlockTable> </apex:pageBlockSection> </apex:pageBlock> <apex:pageBlock title="Inventory Information"> <apex:pageBlockButtons > <apex:commandButton value="Process Selected" action="{!processSelected}" rerender="table"/> </apex:pageBlockButtons> <apex:pageBlockSection title="Select Inventory"> <apex:dataTable value="{!inventory}" var="c" styleClass="list"> <apex:column > <apex:facet name="header">Select</apex:facet> <apex:inputCheckbox value="{!c.selected}" /> </apex:column> <apex:column > <apex:facet name="header">MAC Address</apex:facet> <apex:outputText value="{!c.con.MAC_Address__c}" /> </apex:column> <apex:column > <apex:facet name="header">Appliance Serial Number</apex:facet> <apex:outputText value="{!c.con.name}" /> </apex:column> <apex:column > <apex:facet name="header">Inventory Type</apex:facet> <apex:outputText value="{!c.con.Inventory_Type__c}" /> </apex:column> <apex:column > <apex:facet name="header">Inventory Status</apex:facet> <apex:outputText value="{!c.con.Status__c}" /> </apex:column> <apex:column > <apex:facet name="header">Build Date</apex:facet> <apex:outputText value="{!Month(c.con.Build_Date__c)}/{!Day(c.con.Build_Date__c)}/{!YEAR(c.con.Build_Date__c)}" /> </apex:column> <apex:column > <apex:facet name="header">Account Name</apex:facet> <apex:outputText value="{!c.con.account__r.name}" /> </apex:column> </apex:dataTable> </apex:pageBlockSection> </apex:pageBlock> </apex:form> </apex:page>

 

 I am looking for a way to execute the update on the Inventory__c custom object and appreciate any sample code or references that folks can provide to help with this.

 

Thanks in advance and again sorry for being a noob.

 

Wes

 

 

 

Hi, I have a trigger that just needs to make two fields (Role__c and Product__c) unique for a given contact. When I try to write an error message I get the following System error.

'execution of BeforeUpdate caused by: System.Exception: SObject row does not allow errors:'. The code I am using is ...
Code:
trigger UniqueRoleProductTrigger on Contact_Role__c (before insert, before update)
{
if (Trigger.isBefore)
{
if (Trigger.isUpdate)
{
for (Integer i = 0; i < Trigger.new.size(); i++)
{
Contact_Role__c newRole = Trigger.new[i];

Contact curContact =
[select id, AccountId from Contact where id = :newRole.Contact_Person__c];

Contact_Role__c[] RoleProduct =
[select id, Product__c, Role__c from Contact_Role__c
where id = :newRole.Id];

for (Contact_Role__c r: RoleProduct)
{
if ((r.Product__c == newRole.Product__c) && (r.Role__c == newRole.Role__c))
{
r.addError('Role, Product pair already exists. Can not have duplicate Role-Product pair for the same contact.');
} //end of if statement


} //end of for loop
}
}//end if update
}
}

 I tried Trigger.new.addError as well, but still getting the error. Would greatly appreciate any help.

Thanks

  • January 14, 2008
  • Like
  • 0