Skip to main content

Notifications

Announcements

No record found.

Community site session details

Community site session details

Session Id :
Finance | Project Operations, Human Resources, ...
Answered

Invalid insert Value

(0) ShareShare
ReportReport
Posted on by 90

For background, we have custom feature provided by our consultant to duplicate released product item along with its formula & routing.

it help our Engineering to makes new item as our material is quite common yet our formula use alot of material & the different between product is just a minor. When we copy a Finish Good product, it also copy all the Pegged Supply type item in the formula into new item along with its formula & routing.

in there, we also had our custom field in Invetttable for our internal coding/naming that also copied when we duplicate a product.

So here the case.

our current custom field for our coding/naming use numeric data type. Today we need Character on those custom field. so, i rename the old field & makes new field with string data type & the same name as the old one. i also had adjust some other table, report, & module related to it, doing sync to each affected table, & full cil. most of the module, report already function as intended, it show the new character value naming.

my current problem right now is on the custom duplicate module i mention above. When im duplicating a finish goods product consist of 10 pegged supply type item, it create the a new finish good item & 10 new item as in the pegged supply list as intended but on my custom field, not all copied to the new item. some of them have the copied value, while some others just having 0 value. it happen on random occurence as when i try to diplicate the same item again, i will get different result of which item that get 0 value on my custom field. I have try to debug it, but found nothing. all parameters input is good but as insert() command executed & i check the inserted data, for some reason the inserted value become 0. up to this time, all parameter value on debug mode still good & didnt show any sign it change to 0.

        InventRNDProductTable.CategoryItem      = InventTable.CategoryItem;
        InventRNDProductTable.SubCategoryItem   = InventTable.SubCategoryItem;
        InventRNDProductTable.TypeItem          = InventTable.TypeItem;
        InventRNDProductTable.InventSiteId      = InventTable.SiteId;
        InventRNDProductTable.PurchUnitId       = "";
        InventRNDProductTable.PurchTaxItemGroup = "";
        InventRNDProductTable.Weight            = InventTable.NetWeight;
        InventRNDProductTable.Model             = strFmt("%1%2","XXX-",InventTable.Model);  <<<i purposely add this XXX to ensure if this code is the one that used on the duplicate action & it does.
        InventRNDProductTable.Formula           = InventTable.Formula;
        InventRNDProductTable.ProdPoolId        = InventTable.ProdPoolId;
        InventRNDProductTable.PartName          = InventTable.PartName;
        InventRNDProductTable.SchemaNoInt       = strFmt("%1%2","XXX",InventTable.SeqNoInt);  <<<Issued value not copied on random occurence
        InventRNDProductTable.CustInit          = InventTable.CustInit;
        InventRNDProductTable.AutomaticPart     = InventTable.AutomaticPart;
        InventRNDProductTable.BatchNumGroupId   = InventTable.BatchNumGroupId;
        InventRNDProductTable.DefaultDimension  = InventTable.DefaultDimension;

        InventRNDProductTable.insert();

I have try to do Full CIL, sync all table but the problem still occuring. Im kinda clueless right now.

is there something i miss here?

Thanks.

  • Verified answer
    nmaenpaa Profile Picture
    nmaenpaa 101,156 on at
    RE: Invalid insert Value

    Nice to hear that the issue is resolved.

    I recommend setting up a nightly build on your dev system, with AOS restart, x++ compile and CIL generation to avoid such issues in the future.

  • Verified answer
    ITIPG Profile Picture
    ITIPG 90 on at
    RE: Invalid insert Value

    So today my Development Server ask for Restart after Windows Update.

    i restart the windows & back to my headache issue but to found out that everything works fine as what i want to be.

    i try doing duplicate task multiple times & all works as it should be.

    my guest is that restarting the AOS services fix those problem, tho im not quite understand why but it works.

  • ITIPG Profile Picture
    ITIPG 90 on at
    RE: Invalid insert Value

    Yes its Dev system. the Actual System still run the old code from our consultant.

    as my small code part i put on my 1st post. it basically simple insert command without any condition & i purposely adding XXX to ensure its the code executed. all others field is copied perfectly including XXX part i add in the code, but only this SeqNoInt that the value sometimes turn into 0.

    i have try to duplicate the same item over & over but get different result on each duplicate task i do. sometimes only 1 item get 0 value, some other times 2 or 3 item get 0 value. sometimes its the 1st item get 0 value, but some other times its the 3th item.

  • nmaenpaa Profile Picture
    nmaenpaa 101,156 on at
    RE: Invalid insert Value

    Then either your data is not what you expect or your code doesn't work as you expect. The next step is to reproduce the issue so that you can debug it. You said that so far you didn't manage to reproduce it while debugging. But if you can't do that, there's not much that can be done.

    Is this a dev system? Test? Prod? Does it happen in all systems or one system? 

  • ITIPG Profile Picture
    ITIPG 90 on at
    RE: Invalid insert Value

    i didnt actually change the data type. i rename the old field from SeqNoInt into SeqNoInt2 & create new string field named SeqNoInt. the old field value still exist in different field name & i copy to the new field value from this one renamed field value.

    as the change also affect other module which im also had to change related table data type with the same method, rename the old one & create new with the same name.

    the issue is when im insert new data to RND.SeqNoInt from inventtable.SeqNoInt, this custom field sometimes insert the correct value from inventtable.SeqNoInt & some other times it insert 0 value. I have check the inventtable.SeqNoInt value on debug mode & it return the right value yet when inserted, sometimes it saved as 0 value in RND.SeqNoInt.

  • Suggested answer
    nmaenpaa Profile Picture
    nmaenpaa 101,156 on at
    RE: Invalid insert Value

    You should not change data types of existing fields. When you deploy such change to test/prod, the db sync will fail. And even if it would work, you would lose all data in the old field since actually the database would need to delete the old numeric field and create a new string field.

    So, undo what you have done so far.

    Instead create a new string field with a new name and start using that in your code.

    You also need to develop a job that you run once in test/prod, which copies the existing values from your old field to the new field. Finally, you can remove the old field.

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

Announcing Our 2025 Season 1 Super Users!

A new season of Super Users has arrived, and we are so grateful for the daily…

Vahid Ghafarpour – Community Spotlight

We are excited to recognize Vahid Ghafarpour as our February 2025 Community…

Tip: Become a User Group leader!

Join the ranks of valued community UG leaders

Leaderboard

#1
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 292,494 Super User 2025 Season 1

#2
Martin Dráb Profile Picture

Martin Dráb 231,305 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,156

Leaderboard

Product updates

Dynamics 365 release plans