I don't understand this logic:
"if(name is not None):
thisMboSet = mbo.getThisMboSet()
thisMboSet.setWhere("name in(select displayname from person where displayname=" + name)
thisMboSet.reset()
thisMbo = thisMboSet.getMbo(0)"
If your custom attribute is on assignment and you want to set that assignment record, there is no reason to reset that. What I think you are trying to do is get the person record to get the personid. I think you'd want something like this:
personSet=mbo.getMboSet("$EMXPERSON","PERSON","displayname=:name")
personMbo=personSet.getMbo(0)
if personMbo:
personid=personMbo.getString("PERSONID")
thisMbo.setValue("LABORCODE",personid,thisMbo.NOACCESSCHECK)
That being said, I wouldn't personally feel comfortable with this customization. If you have 2 people named John Smith for example that would be a problem (display name is not unique) and you would randomly grab one of them. If you're on Oracle/DB2, that search would be case sensitive so the users would need to type it identically to how it is on the person record. And even setting LABORCODE to the PERSONID has the potential to fail because there is no requirement that they match and we have seen multiple systems where they don't.
------------------------------
Steven Shull
Projetech Inc.
------------------------------