Hi, I’m trying to use Parm methods to store a variable in a method in class A, and I want to get that value in a method in class B, however, when I try to get the value, it comes empty, I’m not really familiar with Parm methods, could you help me out? this is what I have right now:
public InventTransferId parmInventTransferId(InventTransferId _inventTransferId = inventTransferId)
{
inventTransferId = _inventTransferId;
return inventTransferId;
}
I use parmInventTransferId(“value”) in class A, and I try to get the value back in class B by using inventParmInventTransferId() but I get nothing, I set the parm method in the class where I’m trying to receive the value, and also in a separated class, but the result is the same, could you help me out please? thanks!!
parmInventTransferId() allows you to read or write a value to inventTransferId variable in the given class. If X++ allowed is to declare public fields, you could write code like this: classA.inventTransferId = ‘xyz’. But it’s not possible, therefore you to get/set values through parm methods: classA.parmInventTransferId(‘xyz’). Nothing difficult.
Back to your problem: is parmInventTransferId() and inventParmInventTransferId() the same thing? Also, don’t base your debugging on what you get from the method - use debugger to see the actual variable values. That will show you whether the value was set properly and when it disappears.
Thank you both for your answers, first of all, I made a mistake, the only parm method is parmInventTransferId(), I declared it in class A first, then I created an instance in class B to fill it with a value by using parmInventTransferId(“value”) and then I try to get that value in class A by using just this.parmInventTransferId() but I get nothing.
Class B does not extends class A, is that necessary for parm methods? Thanks!
I’m using two existing classes, abstract class InventTransferUpd extendas UpdateBase, this is the one where I create a new instance of the class WMSShipmentReservation, where I have the parm method declared, something like this:
WMSShipmentReservation wmsShipReservation = new WMSShipmentReservation();
wmsShipReservation.parmInventTransferId(“value”);
WMSShipmentReservation extends RunBase, I call the parm method like this:
str value = this.parmInventTransferId();
But I get nothing, I see that in WMSShipmentReservation class there are two methods, pack and unpack:
Ok, I got what the problem is, after my instantiation of the class that contains the parm method, there is another instance that makes my value to get lost, I could use that instance, however, at that point the value that I need is no longer available, is there any other way to do this?