You need to sign in to do that
Don't have an account?

Priorvalue and New objects
Hi,
I created a custom object called "Account status". I also created a custom field on the account that will store the "Status" value of the account status when it is created and edited. This is working fine. I then created a "Previous Status" field on the account. I created a workflow rule and field update with the formula "TEXT(PRIORVALUE( Rating__c ))". This is working on the edit properly. However, on the creation of a new "Account Status" object, the priorvalue funtion is returning the "Status" value of the new object. Is there a way to get the previous value on new object creation?
I created a custom object called "Account status". I also created a custom field on the account that will store the "Status" value of the account status when it is created and edited. This is working fine. I then created a "Previous Status" field on the account. I created a workflow rule and field update with the formula "TEXT(PRIORVALUE( Rating__c ))". This is working on the edit properly. However, on the creation of a new "Account Status" object, the priorvalue funtion is returning the "Status" value of the new object. Is there a way to get the previous value on new object creation?
All Answers
Can you eloborate ??
Hope this helps !!
trigger test on Account_Rating__c (before insert) {
for(Account_Rating__C a: Trigger.new){
Account_Rating__c oldAccountRatingc = Trigger.oldMap.get(a.ID);
a.test_label__c = oldAccountRatingc.Rating__c;
}
}
The use case you are describing represents the current field value of another object that matches criteria that represents a "previous" characterization. Previous needs to be carefully defined.
I am making the following assumptions:
- Status is a numeric field.
- Status is a required field.
- The value of Status is always unique.
- The intent is always to have the next new Account Status inherit a default Status value that is one greater than the largest Status value of any existing Account Status object, or one (1) if it is the first object being created and there are no existing Account Status objects.
There is no value on the new Account Status object that represents the value of a field on another Account Status object.One way to write a business rule representing your use case for the Status field is as follows:
A trigger on the insert of a new Account Status can include a SOQL query to return the largest Status value from the collection of existing Account Status objects or zero (0) if no objects exist yet, and then one can be added to that number.
I don't yet have enough experience in Salesforce to write a sample trigger quickly, so I'll leave this as an exercise for the reader. I also do not know whether this kind of SOQL reference can be implemented within a formula in a workflow. If so, the criteria would include the ISNEW() function to restrict the execution to only objects that are being created for the first time.