args is a local variable in main() method. You’ve never passed it to the VCInstrumentCreateForm object, therefore you indeed can’t use it there.
You need a variable for holding the Args object (or maybe just the record, if that’s what you’re interested in) in VCInstrumentCreateForm class, and a method that will allow you to set a value to this variable.
Then you can set the in main() like this:
static void main(Args _args)
{
VCInstrumentCreateForm instrumentCreateForm = VCInstrumentCreateForm::construct();
if (!_args || !_args.record())
{
throw error(strFmt("@SYS29104", classStr(VCInstrumentCreateForm)));
}
instrumentCreateForm.parmArgs(_args);
if (instrumentCreateForm.prompt())
{
instrumentCreateForm.run();
}
}
By the way, please always attach a tag with the version (such as AX 2009 or D365FO) when creating a new thread. There are significant differences between versions (for example, AX 2012 came with a new framework for these things), therefore knowing the version is very important for these discussions.