Enum value not getting changed

Hi,

I’ve created a quarantine id field in NCMR table from quarantine table.

If that qid get inserted in NCMR table the status in quarantine table needs to change as Selected.

NCMR Insert method:

public void insert()
{
    InventQuarantineOrder invq;
    str qid;
    ;
    super();
    ttsbegin;
    select forupdate invq where invq.QuarantineId==this.QuarantineId;
    invq.setUnAvail(this.QuarantineId);
    invq.doUpdate();
    ttscommit;
}

in quarantine table:

setunavail

public void setUnAvail(str 20 _Id)
{
    InventQuarantineOrder invq;
    ;
    ttsbegin;
    select forupdate NCMR_Created from invq where invq.QuarantineId == _Id;

        invq.NCMR_Created = QidStatus::Selected;
        invq.doUpdate();

    ttscommit;
}

setavail

public void setAvail(str 20 _Id)
{
    InventQuarantineOrder invq;
    ;
    ttsbegin;
    select forupdate invq where invq.QuarantineId == _Id;

        invq.NCMR_Created = QidStatus::UnSelected;
        invq.doUpdate();

    ttscommit;
}

May I know why its not updating the status?

Thanks.

Do you already have the NCMR record and trying to update the Quarantine ID. Then you need your code in update method (not int the insert method). I have modified your code in insert method and setUnAvail. If you are talking about the updating the quarantine Id, then call the setUnAvail() in update method.

You have unnecessary update in insert method. Try this,

public void insert()
{
;
super();
ttsbegin;
if (this.QuarantineId)
{
this.setUnAvail(this.QuarantineId);
}
ttscommit;
}

public void setUnAvail(InventQuarantineId _quarantineId)
{
InventQuarantineOrder invq;
;
ttsbegin;
invq = InventQuarantineOrder::find(_quarantineId, true);
invq.NCMR_Created = QidStatus::Selected;
invq.doUpdate();
ttscommit;
}

NCMR record is already there and I’m trying to add qid, but this is temporary case…
While creating NCMR record the qid also vl get inserted…

Have you tried the code i suggested?

Yes, Kranthi.

Its working fine now…

But now i dnt need the enum field to be updated.

I added a field in quarantine table as NCMR id which needs to get updated by ncmrid from NCMR table when the quaratine id is inserted…

This is NCMR form where I’m adding qid

this is quarantine form ncmr id vch needs to get updated:

pastedimage1519626547904v2.png

but the problem is whenever i modify the id the previous values id isn’t getting changed.

For ex If i’m giving Qid80 for Ncmr id 50 and if i change the id from 80 to 81 in quarantine form for id its not getting empty…

NCMR id is showing in both qid’s… I don’t want like that…

public void update()
{
    InventQuarantineOrder invq;
    ;
    super();
     //added by sri
                ttsbegin;
                invq = InventQuarantineOrder::find(this.QuarantineId, true);
                invq.InventNonConformanceId =this.InventNonConformanceID;
                invq.doUpdate();
                ttscommit;
}

I tried this coding in both insert and update but the previous value isn’t getting empty…

Where do you have the code for that? Can you show the code?

Yes in insert method and update method of ncmr table…

How to make the previous id has empty, Kranthi and update the new value we’re changing from the lookup?

You don’t have to explicitly empty the previous value and update the new value. Updating it to a new value does that.
I may not be able to tell what’s wrong with your code without looking at your code.

public void insert()
{
   InventQuarantineOrder invq;
    ;
    super();
     //added by sri
                ttsbegin;
                invq = InventQuarantineOrder::find(this.QuarantineId, true);
                invq.InventNonConformanceId =this.InventNonConformanceID;
                invq.doUpdate();
                ttscommit;
}

This is my coding, Kranthi…

Update method is in above replies…

When you update the QuarantineId in NCMR ((if your are modifying the exsting QuarantineId), you have to do two things.

  1. Set the InventNonConformanceId on InventQuarantineOrder (with old quarantine id) to empty - this.orig().QuarantineId - will give you the old id
  2. Set the InventNonConformanceId on newly selected QuarantineId (you are already doing this)

Hi Sri,
NCMR is your customize table??

Yes, Rajaravi…
Its inventnonconformancetable…

  1. Set the InventNonConformanceId on InventQuarantineOrder (with old quarantine id) to empty - this.orig().QuarantineId - will give you the old id

So shall I need to write this coding in modified method of inventquarantinetable?

Please share me one form screen short clearly

case fieldNum(InventQuarantineOrder,InventNonConformanceId):
                    qid=this.orig().QuarantineId;
                    break;

Like this, Kranthi?

I tried like this, Kranthi but the previous qid’s ncmr field isn’t getting empty still its having the NCMR id

shall I need to add relation in quarantine table to ncmr table with ncmr id, Kranthi?

You can do it in update itself. Try the below code,

public void update()
{
InventQuarantineOrder invq, invqOrig;
;
super();
ttsbegin;
if (this.Orig().QuarantineId
&& this.Orig().QuarantineId != this.QuarantineId)
{
invqOrig= InventQuarantineOrder::find(this.Orig().QuarantineId, true);
invqOrig.InventNonConformanceId = “”;
invqOrig.doUpdate();
}
//added by sri

if (this. QuarantineId)
{
invq = InventQuarantineOrder::find(this.QuarantineId, true);
invq.InventNonConformanceId =this.InventNonConformanceID;
invq.doUpdate();
}
ttscommit;
}