• Karen Davis 1
  • NEWBIE
  • 10 Points
  • Member since 2016

  • Chatter
    Feed
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 3
    Questions
  • 4
    Replies
I'm trying to add a condition to a javascript button that already works, but it's not working. If a checkbox called "Allow_new_exam_assessment__c" is true, then I want to execute the rest of the button script. If it's false, I want to generate an error message. Here's what I have - can someone tell me how it should be formatted? (

if('{!Treatment__c.Allow_new_exam_assessment__c}') { 
(this is where the rest of the code is - not putting it all here becuase it confuses things)

else 

alert("An exam assessment already exists for today or yesterday."); 
}
I’m trying to write a before delete trigger on a custom object called  “Dental_Assessment” so that if the ID of the record being deleted is the same as a field on the account it will set that field on the account to null. "Dental_Assessment" is a child object of custom object "Treatment" which is a child object of Account. I thought I had it, but I can’t figure out how to get it to update the account record. can anyone help me with the syntax for doing this?
 
This is my trigger, except line 5 doesn’t work:
 
trigger DeleteID on Dental_Assessment__c (before delete) {
 if(System.Trigger.IsDelete) {
  for (Dental_Assessment__c Assmt: trigger.old) {
    if(Assmt.ID = Assmt.treatment__c.individual__c.Last_Exam_Assmt_Form_ID__c) {
    Assmt.treatment__c.individual__c.Last_Exam_Assmt_Form_ID__c = null; 
   }
   }
   }
}
 
I am not a developer, but I am trying to figure out how to create a button and I've been sent here from the success forum. I have a button that will clone an existing record based on a stored record ID. It works fine, however, if that previous record field is blank (one doesn't exist yet) it errors out in a not very nice way.  What I want to do is any of the following:
1) Disable the button if there is no previous record (stored in the field Account.LastExam_ID__c)
2) Create a cloned record if an ID exists or create a new record if one does not exist
3) If a record does not exist, at least give a nice error message and return them to the original page.

The url (which works) to create a clone is this:
/{!Account_LastExam_ID__c}/e?clone=1&CF00N54000000Px0Y={!Treatment__c.Name}&CF00N54000000Px0Y_lkid={!Treatment__c.Id}&retURL=%2F{!Treatment__c.Id}&RecordType={!IF( Treatment__c.ADA_Code__c ="191", "012540000004Nma", "012540000004NmV")}

The url (which works) to create a new record is this:

/a5U/e?CF00N54000000Px0Y={!Treatment__c.Name}&CF00N54000000Px0Y_lkid={!Treatment__c.Id}&retURL=%2F{!Treatment__c.Id}&RecordType={!IF( Treatment__c.ADA_Code__c ="191", "012540000004Nma", "012540000004NmV")}

I thougth I could make it work by creating a variable that held either "a5U" or the value of "Account_LastExam__c" and another one that held either a blank or "clone=1&" and inserting them into the code like this:
/{!Treatment__c.Clone_button_URL__c}/e?{!Treatment__c.Clone_button_URL_2__c}&CF00N54000000Px0Y={!Treatment__c.Name}&CF00N54000000Px0Y_lkid={!Treatment__c.Id}&retURL=%2F{!Treatment__c.Id}&RecordType={!IF( Treatment__c.ADA_Code__c ="191", "012540000004Nma", "012540000004NmV")}

But it doesn't work. The "clone=1&" doesn't come over correctly. It almost works. But it doesn't work. Any suggestions would be very welcome. 
I’m trying to write a before delete trigger on a custom object called  “Dental_Assessment” so that if the ID of the record being deleted is the same as a field on the account it will set that field on the account to null. "Dental_Assessment" is a child object of custom object "Treatment" which is a child object of Account. I thought I had it, but I can’t figure out how to get it to update the account record. can anyone help me with the syntax for doing this?
 
This is my trigger, except line 5 doesn’t work:
 
trigger DeleteID on Dental_Assessment__c (before delete) {
 if(System.Trigger.IsDelete) {
  for (Dental_Assessment__c Assmt: trigger.old) {
    if(Assmt.ID = Assmt.treatment__c.individual__c.Last_Exam_Assmt_Form_ID__c) {
    Assmt.treatment__c.individual__c.Last_Exam_Assmt_Form_ID__c = null; 
   }
   }
   }
}
 

Hi

We have a custom lookup field that has been created on the Opportunity Line Item object called Product Owner. We would like this to be auto populated with the current user when left blank upon saving. 

We've tried to create a trigger to do this but run into errors upon saving the product line

trigger updatefield on OpportunityLineItem (after insert) {
  user defaultuser = [select id from user where name = 'default user'];
  for (OpportunityLineItem record:trigger.new) {
    if(record.Product_Owner__c ==null) {
      record.Product_Owner__c = defaultuser.id;
    }
  }
}

Any help or advice would be much appreciated.

Thanks,

Snita