To use your example, try this :
Place your object.
In the init :
this addaction ["Search the desk","Desk.sqs"]
Then make the script :
(_this select 0) removeaction (_this select 2)
hint "You have found the code!"
codefound = true
The bolean codefound is used so the paper with the code will be visible when you enter it at the codepad.
Not tested, but I'm pretty sure it works.
PS: You don"t need to run the randomassign script anymore.