Unable to add new rows to UD09 with rest-erp or REST API Help

Currently stuck on trying to add new rows to UD09 using Ice.BO.UD09Svc - GetaNewUD09 with the rest-erp widget. Users enter new row information in textboxes (form structure) and when they click Save, I trigger the REST call to create and add the new row to UD09 (which updates a panel card grid displaying all UD09 rows).

I map the user form input to TransView, and use the respective values for my Key1, Key2, etc. fields in the widget’s method parameters. This is an example of roughly how I aim to pass the ds:

No matter how I structure the JSON (tried wrapping in a “UD09” key, tried wrapping in a “ds” key, etc.) I get a Server 500 error and the REST call “fails” (no new row added, but an empty default response is sent back with all UD09 values blank). Same case with REST API Help–Taking the default response parameter structure that’s provided, I modified only Company and a few Key values and I was still unable to get a new row added.


My response in REST API Help:

My response in dev console (assuming the “u.split” error is related to my incorrect JSON method parameter) ?:

I’m able to add/delete/update UD09 just fine through DMT. On this same dashboard I’m able to update UD09 through a UBAQ grid, just stuck on trying to update with rest-erp! What could I be missing here? I know this can be achieved through a custom function but I’d really like to understand why the app studio widget (or even REST API Help) isn’t working for me.

payload for GetaNewUD09

{
  "ds": {}
}

output → Note that parameters BS, remove the "parameters": { and one } from the end

{
  "parameters": {
    "ds": {
      "UD09": [
        {
          "Company": "MS67964",
          "Key1": "",
          "Key2": "",
          "Key3": "",
          "Key4": "",
          "Key5": "",
          "Character01": "",
          "Character02": "",
          "Character03": "",
          "Character04": "",
          "Character05": "",
          "Character06": "",
          "Character07": "",
          "Character08": "",
          "Character09": "",
          "Character10": "",
          "Number01": 0,
          "Number02": 0,
          "Number03": 0,
          "Number04": 0,
          "Number05": 0,
          "Number06": 0,
          "Number07": 0,
          "Number08": 0,
          "Number09": 0,
          "Number10": 0,
          "Number11": 0,
          "Number12": 0,
          "Number13": 0,
          "Number14": 0,
          "Number15": 0,
          "Number16": 0,
          "Number17": 0,
          "Number18": 0,
          "Number19": 0,
          "Number20": 0,
          "Date01": null,
          "Date02": null,
          "Date03": null,
          "Date04": null,
          "Date05": null,
          "Date06": null,
          "Date07": null,
          "Date08": null,
          "Date09": null,
          "Date10": null,
          "Date11": null,
          "Date12": null,
          "Date13": null,
          "Date14": null,
          "Date15": null,
          "Date16": null,
          "Date17": null,
          "Date18": null,
          "Date19": null,
          "Date20": null,
          "CheckBox01": false,
          "CheckBox02": false,
          "CheckBox03": false,
          "CheckBox04": false,
          "CheckBox05": false,
          "CheckBox06": false,
          "CheckBox07": false,
          "CheckBox08": false,
          "CheckBox09": false,
          "CheckBox10": false,
          "CheckBox11": false,
          "CheckBox12": false,
          "CheckBox13": false,
          "CheckBox14": false,
          "CheckBox15": false,
          "CheckBox16": false,
          "CheckBox17": false,
          "CheckBox18": false,
          "CheckBox19": false,
          "CheckBox20": false,
          "ShortChar01": "",
          "ShortChar02": "",
          "ShortChar03": "",
          "ShortChar04": "",
          "ShortChar05": "",
          "ShortChar06": "",
          "ShortChar07": "",
          "ShortChar08": "",
          "ShortChar09": "",
          "ShortChar10": "",
          "ShortChar11": "",
          "ShortChar12": "",
          "ShortChar13": "",
          "ShortChar14": "",
          "ShortChar15": "",
          "ShortChar16": "",
          "ShortChar17": "",
          "ShortChar18": "",
          "ShortChar19": "",
          "ShortChar20": "",
          "GlobalUD09": false,
          "GlobalLock": false,
          "SysRevID": 0,
          "SysRowID": "00000000-0000-0000-0000-000000000000",
          "BitFlag": 0,
          "RowMod": "A"
        }
      ],
      "UD09Attch": [],
      "ExtensionTables": []
    }
  }
}

fill in data… and pass to update

{
  "ds": {
    "UD09": [
      {
        "Company": "MS67964",
        "Key1": "Testing...",
        "Key2": "",
        "Key3": "",
        "Key4": "",
        "Key5": "",
        "Character01": "",
        "Character02": "",
        "Character03": "",
        "Character04": "",
        "Character05": "",
        "Character06": "",
        "Character07": "",
        "Character08": "",
        "Character09": "",
        "Character10": "",
        "Number01": 0,
        "Number02": 0,
        "Number03": 0,
        "Number04": 0,
        "Number05": 0,
        "Number06": 0,
        "Number07": 0,
        "Number08": 0,
        "Number09": 0,
        "Number10": 0,
        "Number11": 0,
        "Number12": 0,
        "Number13": 0,
        "Number14": 0,
        "Number15": 0,
        "Number16": 0,
        "Number17": 0,
        "Number18": 0,
        "Number19": 0,
        "Number20": 0,
        "Date01": null,
        "Date02": null,
        "Date03": null,
        "Date04": null,
        "Date05": null,
        "Date06": null,
        "Date07": null,
        "Date08": null,
        "Date09": null,
        "Date10": null,
        "Date11": null,
        "Date12": null,
        "Date13": null,
        "Date14": null,
        "Date15": null,
        "Date16": null,
        "Date17": null,
        "Date18": null,
        "Date19": null,
        "Date20": null,
        "CheckBox01": false,
        "CheckBox02": false,
        "CheckBox03": false,
        "CheckBox04": false,
        "CheckBox05": false,
        "CheckBox06": false,
        "CheckBox07": false,
        "CheckBox08": false,
        "CheckBox09": false,
        "CheckBox10": false,
        "CheckBox11": false,
        "CheckBox12": false,
        "CheckBox13": false,
        "CheckBox14": false,
        "CheckBox15": false,
        "CheckBox16": false,
        "CheckBox17": false,
        "CheckBox18": false,
        "CheckBox19": false,
        "CheckBox20": false,
        "ShortChar01": "",
        "ShortChar02": "",
        "ShortChar03": "",
        "ShortChar04": "",
        "ShortChar05": "",
        "ShortChar06": "",
        "ShortChar07": "",
        "ShortChar08": "",
        "ShortChar09": "",
        "ShortChar10": "",
        "ShortChar11": "",
        "ShortChar12": "",
        "ShortChar13": "",
        "ShortChar14": "",
        "ShortChar15": "",
        "ShortChar16": "",
        "ShortChar17": "",
        "ShortChar18": "",
        "ShortChar19": "",
        "ShortChar20": "",
        "GlobalUD09": false,
        "GlobalLock": false,
        "SysRevID": 0,
        "SysRowID": "00000000-0000-0000-0000-000000000000",
        "BitFlag": 0,
        "RowMod": "A"
      }
    ],
    "UD09Attch": [],
    "ExtensionTables": []
  }
}

Bob’s your uncle.

1 Like

Started on a fresh slate for my own sanity. My UD09 table has 97 rows currently.

Here’s my event to add a new row:

My rest-erp setup:

JSON for the Dataset Model:

{
	"ds": {
		"UD09": [
			{
				"Company": "BMF",
				"Key1": "99999",
				"Key2": "88888",
				"Key3": "4",
				"Key4": "Test1",
				"Key5": "Test2",
				"Character01": "",
				"Character02": "",
				"Character03": "",
				"Character04": "",
				"Character05": "",
				"Character06": "",
				"Character07": "",
				"Character08": "",
				"Character09": "",
				"Character10": "",
				"Number01": 0,
				"Number02": 0,
				"Number03": 0,
				"Number04": 0,
				"Number05": 0,
				"Number06": 0,
				"Number07": 0,
				"Number08": 0,
				"Number09": 0,
				"Number10": 0,
				"Number11": 0,
				"Number12": 0,
				"Number13": 0,
				"Number14": 0,
				"Number15": 0,
				"Number16": 0,
				"Number17": 0,
				"Number18": 0,
				"Number19": 0,
				"Number20": 0,
				"Date01": null,
				"Date02": null,
				"Date03": null,
				"Date04": null,
				"Date05": null,
				"Date06": null,
				"Date07": null,
				"Date08": null,
				"Date09": null,
				"Date10": null,
				"Date11": null,
				"Date12": null,
				"Date13": null,
				"Date14": null,
				"Date15": null,
				"Date16": null,
				"Date17": null,
				"Date18": null,
				"Date19": null,
				"Date20": null,
				"CheckBox01": false,
				"CheckBox02": false,
				"CheckBox03": false,
				"CheckBox04": false,
				"CheckBox05": false,
				"CheckBox06": false,
				"CheckBox07": false,
				"CheckBox08": false,
				"CheckBox09": false,
				"CheckBox10": false,
				"CheckBox11": false,
				"CheckBox12": false,
				"CheckBox13": false,
				"CheckBox14": false,
				"CheckBox15": false,
				"CheckBox16": false,
				"CheckBox17": false,
				"CheckBox18": false,
				"CheckBox19": false,
				"CheckBox20": false,
				"ShortChar01": "",
				"ShortChar02": "",
				"ShortChar03": "",
				"ShortChar04": "",
				"ShortChar05": "",
				"ShortChar06": "",
				"ShortChar07": "",
				"ShortChar08": "",
				"ShortChar09": "",
				"ShortChar10": "",
				"ShortChar11": "",
				"ShortChar12": "",
				"ShortChar13": "",
				"ShortChar14": "",
				"ShortChar15": "",
				"ShortChar16": "",
				"ShortChar17": "",
				"ShortChar18": "",
				"ShortChar19": "",
				"ShortChar20": "",
				"GlobalUD09": false,
				"GlobalLock": false,
				"SysRevID": 0,
				"SysRowID": "00000000-0000-0000-0000-000000000000",
				"BitFlag": 0,
				"RowMod": "A"
			}
		],
		"UD09Attch": [],
		"ExtensionTables": []
	}
}

Response in console:

My response from GetaNewUD09 on the network tab:

{
    "parameters": {
        "ds": {
            "UD09": [
                {
                    "Company": "BMF",
                    "Key1": "",
                    "Key2": "",
                    "Key3": "",
                    "Key4": "",
                    "Key5": "",
                    "Character01": "",
                    "Character02": "",
                    "Character03": "",
                    "Character04": "",
                    "Character05": "",
                    "Character06": "",
                    "Character07": "",
                    "Character08": "",
                    "Character09": "",
                    "Character10": "",
                    "Number01": 0.0,
                    "Number02": 0.0,
                    "Number03": 0.0,
                    "Number04": 0.0,
                    "Number05": 0.0,
                    "Number06": 0.0,
                    "Number07": 0.0,
                    "Number08": 0.0,
                    "Number09": 0.0,
                    "Number10": 0.0,
                    "Number11": 0.0,
                    "Number12": 0.0,
                    "Number13": 0.0,
                    "Number14": 0.0,
                    "Number15": 0.0,
                    "Number16": 0.0,
                    "Number17": 0.0,
                    "Number18": 0.0,
                    "Number19": 0.0,
                    "Number20": 0.0,
                    "Date01": null,
                    "Date02": null,
                    "Date03": null,
                    "Date04": null,
                    "Date05": null,
                    "Date06": null,
                    "Date07": null,
                    "Date08": null,
                    "Date09": null,
                    "Date10": null,
                    "Date11": null,
                    "Date12": null,
                    "Date13": null,
                    "Date14": null,
                    "Date15": null,
                    "Date16": null,
                    "Date17": null,
                    "Date18": null,
                    "Date19": null,
                    "Date20": null,
                    "CheckBox01": false,
                    "CheckBox02": false,
                    "CheckBox03": false,
                    "CheckBox04": false,
                    "CheckBox05": false,
                    "CheckBox06": false,
                    "CheckBox07": false,
                    "CheckBox08": false,
                    "CheckBox09": false,
                    "CheckBox10": false,
                    "CheckBox11": false,
                    "CheckBox12": false,
                    "CheckBox13": false,
                    "CheckBox14": false,
                    "CheckBox15": false,
                    "CheckBox16": false,
                    "CheckBox17": false,
                    "CheckBox18": false,
                    "CheckBox19": false,
                    "CheckBox20": false,
                    "ShortChar01": "",
                    "ShortChar02": "",
                    "ShortChar03": "",
                    "ShortChar04": "",
                    "ShortChar05": "",
                    "ShortChar06": "",
                    "ShortChar07": "",
                    "ShortChar08": "",
                    "ShortChar09": "",
                    "ShortChar10": "",
                    "ShortChar11": "",
                    "ShortChar12": "",
                    "ShortChar13": "",
                    "ShortChar14": "",
                    "ShortChar15": "",
                    "ShortChar16": "",
                    "ShortChar17": "",
                    "ShortChar18": "",
                    "ShortChar19": "",
                    "ShortChar20": "",
                    "GlobalUD09": false,
                    "GlobalLock": false,
                    "SysRevID": 0,
                    "SysRowID": "00000000-0000-0000-0000-000000000000",
                    "BitFlag": 0,
                    "RowMod": "A"
                }
            ],
            "UD09Attch": [],
            "ExtensionTables": []
        }
    }
}

Still 97 rows in UD09, no new row added. I know I’m missing something small here..

GetNew doesn’t add a row on the database, all it does is give you an empty to row to fill in.

May I sugest @Mark_Wonsil’s favorite thing and ask that you make a function instead that takes in just the fields you need to add.

It can then do the work, on the server side, and you avoid having to get GetNew, ChangXX, Update etc in the front end.

ALso and this is just a note for your future self, rename your controls before you hoook up events your future self will thank you.

5 Likes

Thanks Jose, I forgot a piece of a sentence in my reply… “pass to update” :rofl:

3 Likes

Btw GetaNewUD09 works well, but GetNewUD09 seems all jacked up. I gave up as it wasn’t worth it.

One of them is deprecated (I can never remember which one)

Hopefully not the one that works…

3 Likes

GetANew is the correct (undeprecated) one

2 Likes

Definitely…this has been driving me nuts all day so I started fresh in a new app with a single button and event to figure out why I can’t get GetaNewUD09 to work..

Trying to wrap my head around what that GetaNewUD09 method is actually doing. Is it modifying a temporary dataset that needs to be committed afterwards with Update? If that’s the case then would every rest-erp call to GetaNewUD09 need a second rest-erp call for Update afterwards?

DeleteByID, GetByID, GetRows, Update, etc. all make sense to me (and I have successfully used them in my apps/REST API help testing) but I’m still unable to understand what I’m missing when trying to use GetaNewUD09 without making a function. Will be going the function route tomorrow…

This is correct

Also correct

This is the reason for this suggestion

3 Likes

You don’t need to spell out the entire dataset in the JSON.

For what its worth, if you want to give it a try, here is my set-up for GetaNewUD02

Method Params:

No Request Params.

Response Params:

Response Params > Dataset:

Don’t try to pre-fill anything IN this rest call. This call is just to create a new row with an empty dataset.

Follow-up your rest-erp with a row-update action to then set your values.

1 Like

Went the function route and looks like I’m running into some context issues with the ‘Db’ variable in the following code:

using (var UD09svc = Ice.Assemblies.ServiceRenderer.GetService<Ice.Contracts.UD09SvcContract>(Db)){

// Create a new record
UD09Tableset ds = new UD09Tableset();

UD09svc.GetaNewUD09(ref ds);

// Set field values
ds.UD09[0].Key1 = "Order123";
ds.UD09[0].Key2 = "Line001";
ds.UD09[0].ShortChar01 = "Custom Data";
ds.UD09[0].Number01 = 100;

// Save the record
UD09svc.Update(ref ds);

}

Receiving Error CS1503: Argument 1: cannot convert from ‘EFx.CONNOR_DEV.Implementation.ILibraryContext’ to ‘Ice.IceDataContext’

My assemblies, tables, and services declared for my function library:

What might I be missing here?

The ‘Db’ context in a function is different.

You can make your own context using the factory (Ice or Erp) but you would usually want to use CallService instead.

CallService<Ice.Contracts.UD09SvcContract>(UD09svc =>
{
    // Create a new record
    UD09Tableset ds = new UD09Tableset();

    UD09svc.GetaNewUD09(ref ds);

    // Set field values
    ds.UD09[0].Key1 = "Order123";
    ds.UD09[0].Key2 = "Line001";
    ds.UD09[0].ShortChar01 = "Custom Data";
    ds.UD09[0].Number01 = 100;

    // Save the record
    UD09svc.Update(ref ds);
});
2 Likes

Also, just add the UD09 Service under the services references. It will bring in everything you need for that automagically. No need to add the individual assemblies.

1 Like

Where’s the best place (other than this forum) to find code examples like this? REST API Help has been a great resource to explore everything Epicor exposes, parameters required for each method call, response structures, etc. but I’ve been struggling to find syntax examples of how to utilize all of these methods programmatically through functions.

1 Like

This forum is your only hope.

4 Likes

Happy If You Say So GIF

3 Likes

Classes / Serialized Json Objects in particular aren’t documented in REST Help, which I think is the main missing piece from it.

I rely on Decompiled code for the missing bits…

1 Like

Maybe we could get an Epicor idea accepted to add this stuff

2 Likes