You need to sign in to do that
Don't have an account?
Justin Deck
Modify the NewURLPolicyCondition Apex Class/Use Apex in Transaction Security Policies
I'm stuck on the Modify the NewURLPolicyCondition Apex Class challenge: Modify the NewURLPolicyCondition Apex class you created in an earlier challenge and change its condition from any time in the past two days to the past week.
I completed the previous challenges in this section with ease but don't see any reference to "in the past two days" so I am not sure how to modify the condition "to the past week".
Please help!
I completed the previous challenges in this section with ease but don't see any reference to "in the past two days" so I am not sure how to modify the condition "to the past week".
Please help!
TRY THIS
All Answers
This is the code you should see in the Apex Class name NewURLPolicyCondition
global class NewURLPolicyCondition implements TxnSecurity.PolicyCondition {
public boolean evaluate(TxnSecurity.Event e) {
AggregateResult[] results = [SELECT ApiType FROM LoginHistory WHERE UserId = :e.userId AND LoginTime = LAST_N_DAYS:2 GROUP BY ApiType];
if(!results.isEmpty() && results.size() > 1) {
return true;
}
return false;
i was stuck on the same exercise,just followed the steps and it works just fine.
Let me know if it worked for you as well.
global class NewURLPolicyCondition implements TxnSecurity.PolicyCondition {
public boolean evaluate(TxnSecurity.Event e) {
AggregateResult[] results = [SELECT ApiType FROM LoginHistory WHERE UserId = :e.userId AND LoginTime = LAST_N_DAYS:2 GROUP BY ApiType];
if(!results.isEmpty() && results.size() > 1) {
return true;
}
return false;
Copy and paste this code, This will help you :)
TRY THIS
If this helps you choose this as Best Answer
This will give you easy to edit option later on in apex class
2) Several people keep repeated "just edit LAST_N_DAYS from 2 to 7". If that was present in the code for everyone, it'd be obvious. Here's what the code in my org looked like, even after completing all the previous challenges successfully.
3) Naveen Dhanaraj (https://dfc-org-production.force.com/forums/ForumsProfile?communityId=09aF00000004HMG&userId=005F0000007EbyP&showHeader=false)'s response above works on the first try.
and here is code which actually help you pass this challenge:
Your answers are the best to solve this exercise.
Thanks,
mah