. I am getting an error that Dialog field object is not initialized

I am trying to use Dialog in the report. I am getting an error that Dialog field object is not initialized… I am using the code given below:

public Object dialog(DialogRunbase _dialog = null)
{
DialogRunBase dialognew;
;
//breakpoint;
dialognew = super(_dialog);
dialognew.caption(“Print Details”);
dialognew.allowUpdateOnSelectCtrl(true);
dialogID = dialognew.addField(typeid(PurchName),“Purchase Name”);
dialogVendorAccount = dialognew.addField(typeid(PurchIdBase),“Purchase ID”);

// dialogID.allowEdit(false);
return dialognew;
}

The error is thrown in the fetch method:

public boolean fetch()
{
PurchTable _PurchTable;
PurchLine _PurchLine;
boolean ret;
;
select _PurchTable join _PurchLine where _PurchTable.PurchId && _PurchLine.PurchId == dialogID.value();

ret = super();

return ret;
}

Please help me to clear this error

Declare a global variable in the class declaration for storing the dialogID.value();.

In getFromDialog() method assign the dialogID.value() to the created variable.

Use that variable in the select statement…