You need to sign in to do that
Don't have an account?
Jerrod Knapp 11
trigger help on ContentVersion
I have a trigger that is "supposed" to recheck a box only if there is a new version of a Content Document and only if the box has been unchecked. I need to be able to uncheck this box and save the record so we can publish. What it's doing right now is re-checking the box whether or not the version is <> '1' (I have even used >'1'). Can someone check this out and tell me where I might be mucking up the code?
trigger NotOnWebCheckbox on ContentVersion (before update) {
for(ContentVersion cv: Trigger.new){
If (cv.VersionNumber <> '1' || cv.Not_on_Web__c == false ){
cv.Not_on_Web__c = true;
}
}
}
Thanks in advance, obviously there will be beer for Best Answer ;)
trigger NotOnWebCheckbox on ContentVersion (before update) {
for(ContentVersion cv: Trigger.new){
If (cv.VersionNumber <> '1' || cv.Not_on_Web__c == false ){
cv.Not_on_Web__c = true;
}
}
}
Thanks in advance, obviously there will be beer for Best Answer ;)
try using the following code:
If it solves the question then please mark it as best answer!
All Answers
try using the following code:
If it solves the question then please mark it as best answer!
Sincerely,
Jerrod
Few reasons I can think of,
1) We need to make sure the excate data type when we compare two versions and so I have make use of String.ValueOf() funciton.
2) I have also added condition which says If (cv.VersionNumber != null) so it will not check against the NULL values (e.g., let's say there is a new reocord entered in the database, at this posint there is no PriorVersionNum for it.
Hope this helps!