You need to sign in to do that
Don't have an account?
Tommy Georgiou
text field not equal to the same value in workflow
Hi all,
I have a custom text field that I want to include into a workflow where my end result will be a field update(checkbox). What I want as a rule is when this custom text field is the same then the update won't take place. ie. when abc1234 = abc 1234 then nothing will happen.
My question is how can I create this rule? (For a contact I have a custom object where it has records. In some cases two records have the same custom text field.)
I have a custom text field that I want to include into a workflow where my end result will be a field update(checkbox). What I want as a rule is when this custom text field is the same then the update won't take place. ie. when abc1234 = abc 1234 then nothing will happen.
My question is how can I create this rule? (For a contact I have a custom object where it has records. In some cases two records have the same custom text field.)
I haven't tested the code. Please check this if it works fine. Also please remove the roll-up field from Contact.
--
Abhi
If my answer helps to solve the issue/problem/doubt, please mark it as Best Answer; so that people who are stuck in the similar issue get benefitted.
All Answers
--
Abhi
If my answer helps to solve the issue/problem/doubt, please mark it as Best Answer; so that people who are stuck in the similar issue get benefitted.
If you look the image below where in red I highlighted the part that is the same. My rule now contains Record Count > 1 and it counts all the records so my checkbox gets checked. What I want though is Yes to calculate the records but when the ReservationCode is the same in each record then it won't count this as a seperate one
If you are already written code, simply put these record's ReservationCode to a set - set doesn't store duplicate records. Now in the end just check the size of the set - you wil get count.
--
Abhi
If my answer helps to solve the issue/problem/doubt, please mark it as Best Answer; so that people who are stuck in the similar issue get benefitted.
Then I created a workflow where when recordcount>1 then a field update that checks the custom checkbox.
But my problem is that I may have more than 3 records with the same reservationcode and I do not want to include them in the process.
contactIds.add(oneReservation.Id);
}
Should be:
if(oneReservation.ReservationStatus__c == 'Confirmed'){
contactIds.add(oneReservation.Contact__c); // the API name of Contact field in Reservation object
}
http://www.salesforce.com/us/developer/docs/soql_sosl/Content/sforce_api_calls_soql_select_agg_functions.htm
--
Abhi
If my answer helps to solve the issue/problem/doubt, please mark it as Best Answer; so that people who are stuck in the similar issue get benefitted.
Since you already have written the trigger, check the workflow condition inside trigger, and update the checkbox too from the trigger code itself. no need of workflow.
--
Abhi
I followed your instruction and changed it to
if(oneReservation.ReservationStatus__c == 'Confirmed'){
contactIds.add(oneReservation.Contact__c);
How to get the COUNT DINSTICT into the trigger?
I haven't tested the code. Please check this if it works fine. Also please remove the roll-up field from Contact.
--
Abhi
If my answer helps to solve the issue/problem/doubt, please mark it as Best Answer; so that people who are stuck in the similar issue get benefitted.
What are you asking in the second part - And supposly yes should be an autonumber? - I did not understand this.
Discard my last comment.
I have tried the trigger but I do get an error like
Error: Compile Error: sObject type 'Reservation__c' is not supported. If you are attempting to use a custom object, be sure to append the '__c' after the entity name. Please reference your WSDL or the describe call for the appropriate names. at line 11 column 35
[Error] Error: Compile Error: Invalid aggregate function: DISTINCT_COUNT at line 11 column 35
Moment of truth!!! It's saved now and I am trying to create and see a test contact if it works. Does this works for existing contacts with existing reservations?
Thank you very much!!!
--
Abhi
I need your help wirting the test class in order to cover the lines and push it into production.
Due to my poor knowledge I think that a test class should include
Account a = new Account(Name = 'Test');
insert a;
Contact c = new Contact(AccountId=a.Id, lastname='testing', firstname='apex', Email= 'xxxxx');
insert c;
but here is where I stuck. How to get the custom object onto the test class with the count dinstinct??
I am trying to insert mass records onto the custom object and I get an error like :
ReservationTrigger: execution of AfterInsert caused by: System.QueryException: Non-selective query against large object type (more than 100000 rows). Consider an indexed filter or contact salesforce.com about custom indexing. Even if a field is indexed a filter might still not be selective when: 1. The filter value includes null (for instance binding with a list that contains null) 2. Data skew exists whereby the number of matching rows is very large (for instance, filtering for a particular foreign key value that occurs many times) Trigger.ReservationTrigger: line 11, column 1
Any Ideas how to overcome this?