function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
FatemehFatemeh 

Validation Rule involving TaskRay Task Lookup Field and TaskRay Time Number Field

Hello,

TaskRay Task Time Field "Hour" (Number field) cannot be changed if the TaskRay Task Project Name (Lookup field) is equal to "New Request" - essentially requiring the user to change the name of the project before they can add time to their task.

I've tried this and it works for preventing users from adding time, but it is also preventing users from adding time when the project name is changed out of "New Request"

AND(
TASKRAY__Hours__c <> 0,
TASKRAY__Project__c <> "New Request"
)


Thank you in advance for your time! :)
Best Answer chosen by Fatemeh
FatemehFatemeh
This is the VR that works:

TASKRAY__Hours__c <> 0 &&
((TASKRAY__Project__r.Name) = "New Request" ||
ISBLANK((TASKRAY__Project__c) )
)

Please mark this as the best answer if it helps someone out there.  :)

All Answers

AnkaiahAnkaiah (Salesforce Developers) 
Hi Fatemeh,

try with below validation rule.
 
AND(
ISCHANGED(TASKRAY__Hours__c),
TASKRAY__Project__c = "New Request"
)

If this helps, Please mark it as best answer.

Thanks!!
FatemehFatemeh
Hi Ankaiah,

Thank you for taking the time to reply to my question. It did not work. Do you have any other ideas that we could try?

Thank you,
Fatemeh
AnkaiahAnkaiah (Salesforce Developers) 
Hi Fatemeh,

The validation works, when TASKRAY__Project__c = "New Request" and you are trying to modify the TASKRAY__Hours__c field. 

Is it not firing?? then check the validation is active or not.

Thanks!!
FatemehFatemeh

Hi Ankaiah,

Thank you. Yes, it is active. Still not firing. Tried refreshing the task, erasing and rebuilding the VR...just in case. Nothing. Please advise.
 

Thank you!

mukesh guptamukesh gupta
Hi Fatemeh,

Please use below code:-
 
AND(
ISCHANGED(TASKRAY__Hours__c),
TASKRAY__Project__r.Name = "New Request"
)

if you need any assistanse, Please let me know!!

Kindly mark my solution as the best answer if it helps you.

Thanks
Mukesh 
FatemehFatemeh
Hi Mukesh,

Thank you for taking the time to help me. It is not firing. I also tried TASKRAY__Project__r.Name <> "New Request" without success. Please advise.

Thank you,
Fatemeh
FatemehFatemeh
Hello,

I have tried various combos without success...here are two:

Attempt #1 (does not fire):
AND(
ISCHANGED(TASKRAY__Hours__c),
TASKRAY__Project__c = "New Request"
)


Attempt #2 (similar to my original VR, fires with new request (correct), but also fires (incorrect) when new request is changed to a new project name:

AND(
TASKRAY__Hours__c <> 0,
TASKRAY__Task__r.TASKRAY__Project__c <> "New Request"
)

Any suggestion would be much appreciated. Thank you!
FatemehFatemeh
This is the VR that works:

TASKRAY__Hours__c <> 0 &&
((TASKRAY__Project__r.Name) = "New Request" ||
ISBLANK((TASKRAY__Project__c) )
)

Please mark this as the best answer if it helps someone out there.  :)
This was selected as the best answer
FatemehFatemeh
I didn't know I could choose my own answer as the best answer! :)