Function wont change part to be serial tracked

Looking for some help here…

I am trying to use a function to change a part to be serial tracked. But for some reason the function does nothing. No error that I can see and the part is not set as Serial Tracked. Usually when that happens I have forgotten to set the RowMod = “U” but not in this case.

Here is the code from the function. I have added a reference to the ERP.BO.Part service.

  // Create PartService BO.
  this.CallService<Erp.Contracts.PartSvcContract>(BO =>
        {
            var ds = BO.GetByID(partNum);
            
            // Set part as serial tracked.
            ds.Part.FirstOrDefault().TrackSerialNum = true;
            ds.Part.FirstOrDefault().RowMod = "U";
            
            BO.ChangePartTrackSerialNum(true, ref ds);
            
            BO.Update(ref ds); 
        });

I have pretty much the same code in a BPM and that is working. The BPM updates other part details as well.

I also did a trace in the client to see what method calls it uses and there was the ChangePartTrackSerialNum call twice. Interestingly that didnt have the rowmod=U.

Thanks
Brett

What are your options setup on your function like?

The library has these options

image

and the function has this…

image

The function did have more code that would first create the part and then set it as serial tracked. That would create the part and set all the other details. I removed all the code to create the part to concentrate on the serial track issue.

I just added a line to edit the part description and that worked so it can edit other details on the part. Doesn’t like the Serial Tracked property…

Does the part you are trying to turn serial tracking on for have any inventory?

good question, its a brand new part so no inventory or any records on any other table (job, po, quote etc).

Is serial tracking turned on at the Site level?

Yep serial tracking is on at the Site. I can also check the track serial check box in the part entry screen so I assume the setup of every thing is good.

Looks good to me. The only other thing I can add is did you do a full trace of turning the flag on and then use that to create the function? If not, you might be missing a method call that needs to happen.

looking at the trace it’s ChangePartTrackSerialNum

If you were going to just attempting to update the flag and forget about any special processing that is done by the BO then you would add the table as a reference, set it to updatable and then use the Db.SaveChanges();

in the middle of doing a system recovery… so responses are slow

Duh it’s right there in your code…Sorry I am a dufus… :frowning:

nah, not a dufus, your busy with a recovery!

I did another trace to double check and updated the function to call the same methods… Still not changing the trackSerial checkbox. And I don’t get any output messages.

updated code.

  // Create PartService BO.
  this.CallService<Erp.Contracts.PartSvcContract>(BO =>
        {
            var ds = BO.GetByID(partNum);
            
            // Set part as serial tracked.
            ds.Part.FirstOrDefault().TrackSerialNum = true;
            ds.Part.FirstOrDefault().EnableSerialNum = true;
            ds.Part.FirstOrDefault().RowMod = "U";
            
            BO.ChangePartTrackSerialNum(true, ref ds);
            BO.ChangePartTrackSerialNum(true, ref ds);
            string cPartChangedMsgText, cPartSNChangedMsgText;
            BO.CheckPartChanges(ds, out cPartChangedMsgText, out cPartSNChangedMsgText);
            
            BO.Update(ref ds); 
            
            output = $"{cPartChangedMsgText} {cPartSNChangedMsgText}";
        });

I did the same…and got nothing just trying the BL tester

I see you have the database access set to Read Only in the function. Change to Read Write and try again
image

1 Like

just tried that and still no go :frowning:

This one is doing my head in!

Just did it in BL tester and guess what nothing. Interestingly there is an EnableTrackSerialNum field which is already set to true.

Interestingly doing it on the screen…

  • Clear the part form
  • enter in the part number
  • check the track serial num checkbox
  • click save

image

The code you posted the first time works perfectly for me. But I had to go in and set a serial mask/format for the part first. I did that in Part entry. I think that’s the piece you’re missing.

3 Likes

I concur on that one

I had two additional messages and was just trying to troll through the trace to get those final bits.

interesting… for me the button to set the SN format is disabled…

did you Check the Track Serial Numbers, then set the format then save?