January 21, 200521 yr Hello. I have a script, which I call with a script parameter, say Task_New is the name of the script. I pass the parent key into the script so I can create a new task, which will be associated with my Parent Project. (psuedo code here) Perform Script [ Task_New ; GetAsText (Projects::prj_ID) ] In my Task_New script. I set the prj_ID_FK of the tasks table to whatever the script param value is I passed in above. Like so: Set Field [ tasks::prj_ID_FK ; Get (ScriptParameter) ] as you can see above, the number passed in via the param is text (ex: "050001" Must I ? say instead of this: Set Field [ tasks::prj_ID_FK ; Get (ScriptParameter) ] Say this? Set Field [ tasks::prj_ID_FK ; GetAsNumber (ScriptParameter) ] thanks in advance, Sincerely, J__
January 25, 200521 yr Author right parameters can be string values. But what I am asking is do you have to use the GetAsNumber () on a string when you set that value into a field, which is of type number ? Are there any coercision issues? thanks, J__
January 25, 200521 yr If you want the number field to only display the number, then yes, you need to use GetAsNumber. It will set it with the full string otherwise, even though it may treat the result as a number.
January 26, 200521 yr Author Queue, thanks for the response. It's not actually a field I display, it's used for a relation as a FK to my Master table.. sorry it's a master - detail relationship. When I create a new detail record i pass as a param the master tables PK ex: GetAsText ( Project::ID_PK ) so i wondered if since Get (ScriptParameter) will be returning this as a string whether there could be any 'wackiness' if I just set the field, rather than saying set field [ tasks::ID ; GetAsNumber ( Get (ScriptParameter) ) ] So, is it ok then? thanks, sincerely, J__
January 26, 200521 yr If Project::ID_PK is a text field, then you'll want Tasks::ID|Project to be text also. I'm curious why you're using GetAsText when passing the Project's ID. If it's a text field, then GetAsText isn't necessary. If you're trying to retain leading zeroes, it should be a text field also.
January 26, 200521 yr Author Curious eh? Good question. The PK field in Projects table is auto increment starting with "0000" and by 1. Magically I get "0002", "0003" and so on. But the field is of type Number. so when I display it I get leading 0's. for my UID I add 05 on the front, so I get "050001" - and this is text. So, this is the field I pass to my Task_New script. I then figure if it's going to be a number, i should say GetAsNumber() , but I suspect (since I am not doing it that way now, that type coercion works) hope that makes it clearer. What do you think? thanks, J__
January 26, 200521 yr A number field with leading zeroes ignores the leading zeroes (at least it does in previous versions; I haven't tested much with 7), so it seems like they should naturally be text anyway. If you use GetAsNumber( ) on "050001", the result is 50001, which may or may not be an issue for you.
Create an account or sign in to comment