• Jacek D
  • NEWBIE
  • 0 Points
  • Member since 2011

  • Chatter
    Feed
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 10
    Questions
  • 19
    Replies

I'm (still) totally green to Apex, so please be patient ;)

 

I have a trigger that updates the record that triggers it and creates a new record in the same object. It works nicely when using 'after update'. But what I actually need that trigger to do is run when a formula changes the value from false to true.

 

That formula is quite complex and using cross-object references and roll-ups to calculate the values, so there is not necessarily an action on the record happening to change the value.

 

My thought was to set it to 'after insert', hoping that the trigger will run every now and then to check whether the conditions are ok to run. But maybe I don't understand properly how this works.

 

Thanks

Hi,

 

I am trying to build a formula that counts empty fields. All fields are numerical. Users may populate them all, but these are not required. So I'd like to count how many fields they did not populate. Here's the number formula I built -- it simply returns 0. Any ideas?

 

IF  ( ISBLANK ( accceptance_assign_to_self_time__c  ) , 1 , 0 ) + 
IF  ( ISBLANK ( response_time__c ) , 1 , 0 ) + 
IF  ( ISBLANK ( clarity__c ) , 1 , 0 ) + 
IF  ( ISBLANK ( grammar__c ) , 1 , 0 ) + 
IF  ( ISBLANK ( spelling__c )  , 1 , 0 ) + 
IF  ( ISBLANK ( punctuation__c ) , 1 , 0 ) + 
IF  ( ISBLANK ( tone__c )  , 1 , 0 ) + 
IF  ( ISBLANK ( accuracy_of_refund_request__c ) , 1 , 0 ) + 
IF  ( ISBLANK ( answered_customer_correctly__c ) , 1 , 0 ) + 
IF  ( ISBLANK ( appropriate_changes_to_account__c ) , 1 , 0 ) + 
IF  ( ISBLANK ( case_categorization__c )  , 1 , 0 ) + 
IF  ( ISBLANK ( escalations__c ) , 1 , 0 ) + 
IF  ( ISBLANK ( follow_up__c ) , 1 , 0 ) + 
IF  ( ISBLANK ( customer_satisfaction__c ) , 1 , 0 ) + 
IF  ( ISBLANK ( follow_procedures_and_guidelines__c) , 1 , 0 )

 

Thanks!

Hi,

 

I have a very long formula:

 

IF (AND (ISBLANK(Phone__c ), ISBLANK (Address__c) , ISBLANK (Hours__c ) , ISBLANK (ID__c)) , null , 
IF (AND (ISBLANK (Phone__c) , OR (NOT(ISBLANK(Address__c)) , NOT (ISBLANK ( Hours__c )), NOT ( ISBLANK ( ID__c )) ) ) , '"' & " " & '"' , '"' & Phone__c & '"' ))

 Above code repeats 10 times in the formula field.

 

It is testing conditions to display 3 variables: a null value, empty quotation marks " " , and the phone number in quotation marks "Phone".

 

Running the formula on all fields (meaning 10 times) results in a compiled formula of more than 5,000 characters. Can you think of a way to shorten it?

 

Thanks

trigger Update_Lookup__c_on_Text_ID__c on Lead (before update, before insert) {
        for (Lead l : Trigger.new){
        if(l.Lookup__c !=l.Text_ID__c){
        l.Lookup__c=l.Text_ID__c;
        }
        }
}

 I'm trying to run above trigger when importing new leads. I need the content from field "Text_ID__c" to populate the custom lookup field "Lookup__c". any idea what I'm doing wrong?

 

I'm pretty new to this...

  • September 28, 2011
  • Like
  • 0

I want a workflow rule to be fired if the parent or grandparent changes. Sadly my knowledge of Apex code is limited.

 

I was wondering if anyone already thought up a trigger for this and can help me with the basic structure?

 

That would be great,

 

Thanks!

I asked this also in Formulas and Validation rules, but I think this might be the better location:

 

I want to run a workflow depending on edits on an object, its parent or grandparent.

 

Do you have an idea how to make this happen?

 

Thanks!

I am trying to think of a way to run a workflow on a custom object depending on an edit of the object itself, or its parent or grandparent. Meaning, everytime each of those gets updated, the workflow should run.


I tried this forumula using LastModifiedDate as the indicator, but I got an error message.


OR ( LastModifiedDate != priorvalue ( LastModifiedDate ) , 
Campaign_2__r.LastModifiedDate != priorvalue ( Campaign_2__r.LastModifiedDate ) ,
Campaign_2__r.Contract__r.LastModifiedDate != priorvalue ( Campaign_2__r.Contract__r.LastModifiedDate ))

Error: The PRIORVALUE function cannot reference the Campaign_2__r.LastModifiedDate field.


Hi,

 

I receive the following error on my formula: Error: Incorrect parameter for function 'If()'. Expected Text, received Boolean

 

Any suggestions why?

 

Thanks!

 

If ( OR (  Delete_Flight__c = true ,  Campaign_2__r.Delete_Flights__c = true ) , "Delete" ,

If ( Export_Confirmation_Result__c == "Insert - Success" , "None" ,

If ( Export_Confirmation_Result__c == "Insert - Fail" , Needs_review__c == True ,

If ( OR (  LastModifiedDate >  DateTime_Sent__c ,  Campaign_2__r.LastModifiedDate >  DateTime_Sent__c ,  Campaign_2__r.Contract__r.LastModifiedDate >  DateTime_Sent__c ) , "Update" ,

If ( Export_Confirmation_Result__c == "Update - Success" , "None" ,

If ( Export_Confirmation_Result__c == "Update - Fail" , Needs_review__c == True ,

If ( Export_Confirmation_Result__c == "Delete - Success" , "None" ,

If ( Export_Confirmation_Result__c == "Delete - Fail" , Needs_review__c == true ,

null ))))))))

 

Hi,

 

I've been working in Salesforce for 4 months now and figured that Apex is a much more elegant way to solve some issues I ran into. Being relatively clueless about coding, but curious and open-minded, I am hoping you guys can help me.

 

I ran into this issue while populating a child object: The child needs to display the content of a HTML field of its parents. While text only can be done with a field update, the parent also includes a graphic. Is that possible?

 

And if so, how can I trigger field updates across objects with Apex (meaning, how do I create a link to a different object)?

 

Thanks,

 

Jacek

I'd like to run an Apex trigger that updates the owner field on the contract page once the contract is successfully approved. I know how to update the owner field, but I don't know how to make the trigger run at the given time.

Any suggestions on how to do that?

Thanks!

I'm (still) totally green to Apex, so please be patient ;)

 

I have a trigger that updates the record that triggers it and creates a new record in the same object. It works nicely when using 'after update'. But what I actually need that trigger to do is run when a formula changes the value from false to true.

 

That formula is quite complex and using cross-object references and roll-ups to calculate the values, so there is not necessarily an action on the record happening to change the value.

 

My thought was to set it to 'after insert', hoping that the trigger will run every now and then to check whether the conditions are ok to run. But maybe I don't understand properly how this works.

 

Thanks

Hi,

 

I am trying to build a formula that counts empty fields. All fields are numerical. Users may populate them all, but these are not required. So I'd like to count how many fields they did not populate. Here's the number formula I built -- it simply returns 0. Any ideas?

 

IF  ( ISBLANK ( accceptance_assign_to_self_time__c  ) , 1 , 0 ) + 
IF  ( ISBLANK ( response_time__c ) , 1 , 0 ) + 
IF  ( ISBLANK ( clarity__c ) , 1 , 0 ) + 
IF  ( ISBLANK ( grammar__c ) , 1 , 0 ) + 
IF  ( ISBLANK ( spelling__c )  , 1 , 0 ) + 
IF  ( ISBLANK ( punctuation__c ) , 1 , 0 ) + 
IF  ( ISBLANK ( tone__c )  , 1 , 0 ) + 
IF  ( ISBLANK ( accuracy_of_refund_request__c ) , 1 , 0 ) + 
IF  ( ISBLANK ( answered_customer_correctly__c ) , 1 , 0 ) + 
IF  ( ISBLANK ( appropriate_changes_to_account__c ) , 1 , 0 ) + 
IF  ( ISBLANK ( case_categorization__c )  , 1 , 0 ) + 
IF  ( ISBLANK ( escalations__c ) , 1 , 0 ) + 
IF  ( ISBLANK ( follow_up__c ) , 1 , 0 ) + 
IF  ( ISBLANK ( customer_satisfaction__c ) , 1 , 0 ) + 
IF  ( ISBLANK ( follow_procedures_and_guidelines__c) , 1 , 0 )

 

Thanks!

Hi,

 

I have a very long formula:

 

IF (AND (ISBLANK(Phone__c ), ISBLANK (Address__c) , ISBLANK (Hours__c ) , ISBLANK (ID__c)) , null , 
IF (AND (ISBLANK (Phone__c) , OR (NOT(ISBLANK(Address__c)) , NOT (ISBLANK ( Hours__c )), NOT ( ISBLANK ( ID__c )) ) ) , '"' & " " & '"' , '"' & Phone__c & '"' ))

 Above code repeats 10 times in the formula field.

 

It is testing conditions to display 3 variables: a null value, empty quotation marks " " , and the phone number in quotation marks "Phone".

 

Running the formula on all fields (meaning 10 times) results in a compiled formula of more than 5,000 characters. Can you think of a way to shorten it?

 

Thanks

trigger Update_Lookup__c_on_Text_ID__c on Lead (before update, before insert) {
        for (Lead l : Trigger.new){
        if(l.Lookup__c !=l.Text_ID__c){
        l.Lookup__c=l.Text_ID__c;
        }
        }
}

 I'm trying to run above trigger when importing new leads. I need the content from field "Text_ID__c" to populate the custom lookup field "Lookup__c". any idea what I'm doing wrong?

 

I'm pretty new to this...

  • September 28, 2011
  • Like
  • 0

I am trying to think of a way to run a workflow on a custom object depending on an edit of the object itself, or its parent or grandparent. Meaning, everytime each of those gets updated, the workflow should run.


I tried this forumula using LastModifiedDate as the indicator, but I got an error message.


OR ( LastModifiedDate != priorvalue ( LastModifiedDate ) , 
Campaign_2__r.LastModifiedDate != priorvalue ( Campaign_2__r.LastModifiedDate ) ,
Campaign_2__r.Contract__r.LastModifiedDate != priorvalue ( Campaign_2__r.Contract__r.LastModifiedDate ))

Error: The PRIORVALUE function cannot reference the Campaign_2__r.LastModifiedDate field.


Hi,

 

I receive the following error on my formula: Error: Incorrect parameter for function 'If()'. Expected Text, received Boolean

 

Any suggestions why?

 

Thanks!

 

If ( OR (  Delete_Flight__c = true ,  Campaign_2__r.Delete_Flights__c = true ) , "Delete" ,

If ( Export_Confirmation_Result__c == "Insert - Success" , "None" ,

If ( Export_Confirmation_Result__c == "Insert - Fail" , Needs_review__c == True ,

If ( OR (  LastModifiedDate >  DateTime_Sent__c ,  Campaign_2__r.LastModifiedDate >  DateTime_Sent__c ,  Campaign_2__r.Contract__r.LastModifiedDate >  DateTime_Sent__c ) , "Update" ,

If ( Export_Confirmation_Result__c == "Update - Success" , "None" ,

If ( Export_Confirmation_Result__c == "Update - Fail" , Needs_review__c == True ,

If ( Export_Confirmation_Result__c == "Delete - Success" , "None" ,

If ( Export_Confirmation_Result__c == "Delete - Fail" , Needs_review__c == true ,

null ))))))))

 

I'd like to run an Apex trigger that updates the owner field on the contract page once the contract is successfully approved. I know how to update the owner field, but I don't know how to make the trigger run at the given time.

Any suggestions on how to do that?

Thanks!