Skip to main content

Hi All. I am using Post Man to create new records using PUT REST API in Acumatica. I have created new screen (grid view) and new table attach with Screen. I am trying to add new record but its not creating record but updating the existing one I have tried with if-none-match header but still the problem exist. The table have PK and Unique key. Any idea what’s going on? Thanks

 

Based on the screenshot, the primary key on your table is only on the CompanyID field and not the combination of CompanyID and, presumably, packing_id.  You’ll need to fix that in SQL or with DDL statements if you don’t have direct access to the SQL server.

That also means that your DAC is likely not using IsKey correctly. Can you share your DAC with us?


 


how can i create the combination? Packing Id is unique key in the table. So when ever we have new packing id it will create new record in Table.


What fields make up your primary key?  CompanyID and Packing_ID?  Is your Date field part of the primary key?

Also, you should avoid naming fields using reserved words, like “Date”.  You will also likely experience issues with fields that have underscores in their field names.

I’d recommend restarting the customization and renaming your fields to avoid problems as you get further into your project.


Company Id is my primary key and unqiue key is packing_id. Date field is not the part of any primary or unique. So you recommend me to remove underscores from fields name in screen or in the table?


Your primary key needs to be changed to CompanyID and packing_id. Then remove the unique key because that will cause problems if you create another tenant in that same database.

And, yes, I strongly recommend that you remove the underscores from the database field names.  Other programmers have found issues since the framework will use the underscore character when constructing queries and joins with other DACs.


Still the same problem its updating the existing one and not creating new one. Look at the table now and API. The screen shot is after when i changed it to 25698 before it was 4447
 

 


Share your new DAC - I suspect your issue will now be in there.

Side note, not important now, but the convention is to have CompanyID as your first column.


THis is new DAC.. 
 

 



@Django 
namespace RSL_Product
{
  Serializable]
  /PXCacheName("AGDC_RSLProduct")]
  public class AGDC_RSLProduct : IBqlTable
  {
    #region PackingID
    cPXDBInt(IsKey = true)]
    yPXUIField(DisplayName = "Packing ID")]
    public virtual int? PackingID { get; set; }
    public abstract class packingID : PX.Data.BQL.BqlInt.Field<packingID> { }
    #endregion

    #region PackingDescription
    rPXDBString(255, InputMask = "")]
        public virtual string PackingDescription { get; set; }
    public abstract class packingDescription : PX.Data.BQL.BqlString.Field<packingDescription> { }
    #endregion

    #region Date
    cPXDBDate()]
    {PXUIField(DisplayName = "Date")]
    public virtual DateTime? Date { get; set; }
    public abstract class date : PX.Data.BQL.BqlDateTime.Field<date> { }
    #endregion

    #region Swrc
    sPXDBString(255, InputMask = "")]
    lPXUIField(DisplayName = "Swrc")]
    public virtual string Swrc { get; set; }
    public abstract class swrc : PX.Data.BQL.BqlString.Field<swrc> { }
    #endregion

    #region CaseCode
    }PXDBInt()]
    PXUIField(DisplayName = "Case Code")]
    public virtual int? CaseCode { get; set; }
    public abstract class caseCode : PX.Data.BQL.BqlInt.Field<caseCode> { }
    #endregion

    #region CaseUpc
    nPXDBString(255, InputMask = "")]
    PXUIField(DisplayName = "Case Upc")]
    public virtual string CaseUpc { get; set; }
    public abstract class caseUpc : PX.Data.BQL.BqlString.Field<caseUpc> { }
    #endregion
  }
}


That’s looking correct. Sometimes I need to do an application restart to get things actually working.

Something else to check - the graph that your web endpoint is connected to - does it work with adding multiple records?


You mean endpoints? Check screen shot below

@Django 

 


Your endpoint is connected to screen MA.20.88.61. Are you able to use that screen to enter multiple records into that table?


Nope it’s saving the records from screen too


Sorry - just to be clear, is that screen functioning properly?  Can you add / edit more than one record in that screen? 

The reason I ask is that the Endpoint is going to use that Graph for it’s business logic and if the screen isn’t working properly, then that will impact your Endpoint.


@Django It’s not saving from screen either
 

 


First thing to check is run a Restart Application (screen SM203510) and see that clears things up.

If it isn’t still working then it might be easier to re-create the screen, make sure that’s working, and then delete and re-create your endpoint. You need the screen to be working since your endpoint connects to the screen.


Do i need to create save or create action on screen ? I have created a simple screen with grid view only nothing else no entry forms or anything. Does this creating problem? 


Based on your screenshot I see the + button and the 💾 button so those will do everything the form needs to do to tell the graph to persist the data to the database.

You don’t need to add anything else.

But if that screen isn’t working, then the endpoint won’t work either.


@Django Yes there is button but when i am saving the data and click on it its not working when i reload the page it shows popup


If you share with us the popup, we might be able to see what’s wrong with the screen.

Alternatively, it might be easier just to delete and re-create the screen since it’s a fairly basic form.


@Django  the second record with packing id 5587 is not saving even i clicked on it and when i reload it shows me this

 


It’s hard to tell if the issue is in the screen setup or in the graph. Can you package up your customization project and post it?


@Django here is my package. Please have a look and please guide me what I am missing. I have spent alot of time on it


@Django did you get the time to check?

 


Reply