Question

Work with subcontracts

  • 13 February 2023
  • 27 replies
  • 278 views

Userlevel 4
Badge +2

Hi,

My application generates REST request which is used for creating Bills

This is my request for creating Bill

URL : https://mcicj.acumatica.com/entity/ARTSDocAlphaEndpoint/20.200.001/Bill

Body :

{

  "VendorRef": {

    "value": "1ABL-217i941"

  },

  "DueDate": {

    "value": "3/2/2023"

  },

  "Vendor": {

    "value": "V-06702"

  },

  "Date": {

    "value": "1/31/2023"

  },

  "Terms": {

    "value": "PWP"

  },

  "PostPeriod": {

    "value": "01-2023"

  },

  "Details": [

    {

      "Description": {

        "value": "Line 001 - Gypcrete"

      },

      "Qty": {

        "value": 1

      },

      "UnitCost": {

        "value": "34573.2"

      },

      "ExtendedCost": {

        "value": "34573.2"

      },

      "Account": {

        "value": "5430"

      },

      "SubcontractLine": {

        "value": "1"

      },

      "SubcontractNbr": {

        "value": "234567"

      },

      "rowNumber": {

        "value": "1"

      }

This request is fully workable.

Bill is successfully created, however these 2 fields are missed

I can add them only via “Enter AP Bill” button

 

How to do same via request ?

Is is possible to omit actions usage ?

If not, how to do it properly

Previously, I had experience with default actions for Bill that are depicted at screen

For using them it was enough to send such request 

How to same with subcontracts ?

 

Client’s Acumatica already contains such actions for this entity

I assume that I need to use addSubContractLines action as I need to add these fields to Bill’s columns in Details

However this action does not contain any parameters

My question is : how to use action for adding these custom fields : SubcontractNbr and SubcontractLine to Bill and how to form such request ?

Thanks in Advance


27 replies

Userlevel 7
Badge +11

Hi @Ivan ,

Select the endpoint and the Bills Entity, select the Details, and click on the Extend the entity. Then click on the + button and add the custom fields.

Then check with the API call with the fields.

 

Userlevel 4
Badge +2

Hi @Ivan ,

Select the endpoint and the Bills Entity, select the Details, and click on the Extend the entity. Then click on the + button and add the custom fields.

Then check with the API call with the fields.

 

Hi @jinin 

Thanks for response

I have added these fields previously to endpoint. Maybe I have done it in wrong way ?

 

Userlevel 7
Badge +11

Hi @Ivan ,

Select the endpoint and the Bills Entity, select the Details, and click on the Extend the entity. Then click on the + button and add the custom fields.

Then check with the API call with the fields.

 

Hi @jinin 

Thanks for response

I have added these fields previously to endpoint. Maybe I have done it in wrong way ?

 

Able to update the fields on the screen?

Userlevel 4
Badge +2

Hi @Ivan ,

Select the endpoint and the Bills Entity, select the Details, and click on the Extend the entity. Then click on the + button and add the custom fields.

Then check with the API call with the fields.

 

Hi @jinin 

Thanks for response

I have added these fields previously to endpoint. Maybe I have done it in wrong way ?

 

Able to update the fields on the screen?

@jinin I did not understand, how to update ?

Userlevel 7
Badge +11

Hi @Ivan ,

Select the endpoint and the Bills Entity, select the Details, and click on the Extend the entity. Then click on the + button and add the custom fields.

Then check with the API call with the fields.

 

Hi @jinin 

Thanks for response

I have added these fields previously to endpoint. Maybe I have done it in wrong way ?

 

Able to update the fields on the screen?

@jinin I did not understand, how to update ?

Able to add values for these fields and save records?

Userlevel 4
Badge +2

Hi @Ivan ,

Select the endpoint and the Bills Entity, select the Details, and click on the Extend the entity. Then click on the + button and add the custom fields.

Then check with the API call with the fields.

 

Hi @jinin 

Thanks for response

I have added these fields previously to endpoint. Maybe I have done it in wrong way ?

 

Able to update the fields on the screen?

@jinin I did not understand, how to update ?

Able to add values for these fields and save records?

NO

Userlevel 4
Badge +2

Hi @Ivan ,

Select the endpoint and the Bills Entity, select the Details, and click on the Extend the entity. Then click on the + button and add the custom fields.

Then check with the API call with the fields.

 

Hi @jinin 

Thanks for response

I have added these fields previously to endpoint. Maybe I have done it in wrong way ?

 

Able to update the fields on the screen?

@jinin I did not understand, how to update ?

Able to add values for these fields and save records?

Result remains the same

 

Userlevel 7
Badge +11

Hi @Ivan ,

Select the endpoint and the Bills Entity, select the Details, and click on the Extend the entity. Then click on the + button and add the custom fields.

Then check with the API call with the fields.

 

Hi @jinin 

Thanks for response

I have added these fields previously to endpoint. Maybe I have done it in wrong way ?

 

Able to update the fields on the screen?

@jinin I did not understand, how to update ?

Able to add values for these fields and save records?

NO

If unable to do on the screen, API call also should not support. Please review this issue first. Then try with the endpoint.

Userlevel 4
Badge +2

Hi @Ivan ,

Select the endpoint and the Bills Entity, select the Details, and click on the Extend the entity. Then click on the + button and add the custom fields.

Then check with the API call with the fields.

 

Hi @jinin 

Thanks for response

I have added these fields previously to endpoint. Maybe I have done it in wrong way ?

 

Able to update the fields on the screen?

@jinin I did not understand, how to update ?

Able to add values for these fields and save records?

NO

If unable to do on the screen, API call also should not support. Please review this issue first. Then try with the endpoint.

@jinin  I can’t input it manually here

only can do this via this button “eNTER aP BILL”

which is located in subcontract item 

 

Userlevel 7
Badge +11

Hi @Ivan

 

Try like below

  • Add the addSubcontractLine action. Populate the field from Details

 

  • Add the field “SubcontractNbr”. Try the same with post man

Request:

{
"entity": {
"ReferenceNbr": {
"value": "002962"
},
"Type": {
"value": "Bill"
}
},
"parameters": {
"SubcontractNbr": {
"value": "SC-000034"
}

}
}

 

Userlevel 4
Badge +2

Hi @Ivan

 

Try like below

  • Add the addSubcontractLine action. Populate the field from Details

 

  • Add the field “SubcontractNbr”. Try the same with post man

Request:

{
"entity": {
"ReferenceNbr": {
"value": "002962"
},
"Type": {
"value": "Bill"
}
},
"parameters": {
"SubcontractNbr": {
"value": "SC-000034"
}

}
}

 

Thank you very much. I will check it now and let you know

Userlevel 4
Badge +2

Hi @Ivan

 

Try like below

  • Add the addSubcontractLine action. Populate the field from Details

 

  • Add the field “SubcontractNbr”. Try the same with post man

Request:

{
"entity": {
"ReferenceNbr": {
"value": "002962"
},
"Type": {
"value": "Bill"
}
},
"parameters": {
"SubcontractNbr": {
"value": "SC-000034"
}

}
}

 

I receive such error 

{

    "message": "An error has occurred.",

    "exceptionMessage": "Bill.CashDiscountDate: 'Cash Discount Date' cannot be empty.\nBill.DueDate: 'Due Date' cannot be empty.\nBill.PostPeriod: Error: The 02-2023 financial period is inactive in the MISTICK company.\nBill.Terms: 'Terms' cannot be empty.\nBill.Vendor: 'Vendor' cannot be empty.\nBill.VendorRef: 'Vendor Ref.' cannot be empty.\n'VendorLocationID' cannot be empty.\nVendorLocationID: 'VendorLocationID' cannot be empty.",

    "exceptionType": "PX.Api.ContractBased.OutcomeEntityHasErrorsException",

    "stackTrace": "   at PX.Api.ContractBased.EntityService.GetOperationResult(EntityImpl entity, EntityExportContextBuilder entityExportContextBuilder, PXSYTable exportedKeys, PXOuterException contextError, Boolean throwOnError, Boolean addCancelCommand)\r\n   at PX.Api.ContractBased.EntityService.Put(ISystemContract systemContract, String version, String name, EntityImpl entity, CbOperationContext operationContext, Boolean throwOnError)\r\n   at PX.Api.ContractBased.Soap.SoapFacadeBase.PutImpl(EntityImpl entity, Boolean throwOnValidationError)\r\n   at PX.Api.ContractBased.SystemContracts.V2.RestController.PutEntity(EntityImpl entity, String select, String filter, String expand, String custom)\r\n   at lambda_method(Closure , Object , Object[] )\r\n   at System.Web.Http.Controllers.ReflectedHttpActionDescriptor.ActionExecutor.<>c__DisplayClass6_2.<GetExecutor>b__2(Object instance, Object[] methodParameters)\r\n   at System.Web.Http.Controllers.ReflectedHttpActionDescriptor.ExecuteAsync(HttpControllerContext controllerContext, IDictionary`2 arguments, CancellationToken cancellationToken)\r\n--- End of stack trace from previous location where exception was thrown ---\r\n   at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()\r\n   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)\r\n   at System.Web.Http.Controllers.ApiControllerActionInvoker.<InvokeActionAsyncCore>d__1.MoveNext()\r\n--- End of stack trace from previous location where exception was thrown ---\r\n   at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()\r\n   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)\r\n   at System.Web.Http.Filters.ActionFilterAttribute.<CallOnActionExecutedAsync>d__6.MoveNext()\r\n--- End of stack trace from previous location where exception was thrown ---\r\n   at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()\r\n   at System.Web.Http.Filters.ActionFilterAttribute.<CallOnActionExecutedAsync>d__6.MoveNext()\r\n--- End of stack trace from previous location where exception was thrown ---\r\n   at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()\r\n   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)\r\n   at System.Web.Http.Filters.ActionFilterAttribute.<ExecuteActionFilterAsyncCore>d__5.MoveNext()\r\n--- End of stack trace from previous location where exception was thrown ---\r\n   at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()\r\n   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)\r\n   at System.Web.Http.Filters.ActionFilterAttribute.<CallOnActionExecutedAsync>d__6.MoveNext()\r\n--- End of stack trace from previous location where exception was thrown ---\r\n   at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()\r\n   at System.Web.Http.Filters.ActionFilterAttribute.<CallOnActionExecutedAsync>d__6.MoveNext()\r\n--- End of stack trace from previous location where exception was thrown ---\r\n   at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()\r\n   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)\r\n   at System.Web.Http.Filters.ActionFilterAttribute.<ExecuteActionFilterAsyncCore>d__5.MoveNext()\r\n--- End of stack trace from previous location where exception was thrown ---\r\n   at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()\r\n   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)\r\n   at System.Web.Http.Controllers.ActionFilterResult.<ExecuteAsync>d__5.MoveNext()\r\n--- End of stack trace from previous location where exception was thrown ---\r\n   at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()\r\n   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)\r\n   at System.Web.Http.Filters.AuthorizationFilterAttribute.<ExecuteAuthorizationFilterAsyncCore>d__3.MoveNext()\r\n--- End of stack trace from previous location where exception was thrown ---\r\n   at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()\r\n   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)\r\n   at System.Web.Http.Controllers.ExceptionFilterResult.<ExecuteAsync>d__6.MoveNext()\r\n--- End of stack trace from previous location where exception was thrown ---\r\n   at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()\r\n   at System.Web.Http.Controllers.ExceptionFilterResult.<ExecuteAsync>d__6.MoveNext()\r\n--- End of stack trace from previous location where exception was thrown ---\r\n   at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()\r\n   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)\r\n   at System.Web.Http.Dispatcher.HttpControllerDispatcher.<SendAsync>d__15.MoveNext()"

}

 

Is there any specials requirements to do this ? 

Userlevel 4
Badge +2

Hi @Ivan

 

Try like below

  • Add the addSubcontractLine action. Populate the field from Details

 

  • Add the field “SubcontractNbr”. Try the same with post man

Request:

{
"entity": {
"ReferenceNbr": {
"value": "002962"
},
"Type": {
"value": "Bill"
}
},
"parameters": {
"SubcontractNbr": {
"value": "SC-000034"
}

}
}

 

Thank you very much. I will check it now and let you know

I receive such error 

{

    "message": "An error has occurred.",

    "exceptionMessage": "Bill.CashDiscountDate: 'Cash Discount Date' cannot be empty.\nBill.DueDate: 'Due Date' cannot be empty.\nBill.PostPeriod: Error: The 02-2023 financial period is inactive in the MISTICK company.\nBill.Terms: 'Terms' cannot be empty.\nBill.Vendor: 'Vendor' cannot be empty.\nBill.VendorRef: 'Vendor Ref.' cannot be empty.\n'VendorLocationID' cannot be empty.\nVendorLocationID: 'VendorLocationID' cannot be empty.",

}

 

Is there any specials requirements to do this ? 

Userlevel 7
Badge +11

Hi @Ivan

 

Try like below

  • Add the addSubcontractLine action. Populate the field from Details

 

  • Add the field “SubcontractNbr”. Try the same with post man

Request:

{
"entity": {
"ReferenceNbr": {
"value": "002962"
},
"Type": {
"value": "Bill"
}
},
"parameters": {
"SubcontractNbr": {
"value": "SC-000034"
}

}
}

 

Thank you very much. I will check it now and let you know

I receive such error 

{

    "message": "An error has occurred.",

    "exceptionMessage": "Bill.CashDiscountDate: 'Cash Discount Date' cannot be empty.\nBill.DueDate: 'Due Date' cannot be empty.\nBill.PostPeriod: Error: The 02-2023 financial period is inactive in the MISTICK company.\nBill.Terms: 'Terms' cannot be empty.\nBill.Vendor: 'Vendor' cannot be empty.\nBill.VendorRef: 'Vendor Ref.' cannot be empty.\n'VendorLocationID' cannot be empty.\nVendorLocationID: 'VendorLocationID' cannot be empty.",

}

 

Is there any specials requirements to do this ? 

No special requirements.

Step 1  -Make a PUT call to create a Bill (Same you are using to create a Bill)
Step 2- Make a second call to update the SubcontractNbr using the post API call.

We can't do both at a time.

Userlevel 4
Badge +2

Hi @Ivan

 

Try like below

  • Add the addSubcontractLine action. Populate the field from Details

 

  • Add the field “SubcontractNbr”. Try the same with post man

Request:

{
"entity": {
"ReferenceNbr": {
"value": "002962"
},
"Type": {
"value": "Bill"
}
},
"parameters": {
"SubcontractNbr": {
"value": "SC-000034"
}

}
}

 

Thank you very much. I will check it now and let you know

I receive such error 

{

    "message": "An error has occurred.",

    "exceptionMessage": "Bill.CashDiscountDate: 'Cash Discount Date' cannot be empty.\nBill.DueDate: 'Due Date' cannot be empty.\nBill.PostPeriod: Error: The 02-2023 financial period is inactive in the MISTICK company.\nBill.Terms: 'Terms' cannot be empty.\nBill.Vendor: 'Vendor' cannot be empty.\nBill.VendorRef: 'Vendor Ref.' cannot be empty.\n'VendorLocationID' cannot be empty.\nVendorLocationID: 'VendorLocationID' cannot be empty.",

}

 

Is there any specials requirements to do this ? 

No special requirements.

Step 1  -Make a PUT call to create a Bill (Same you are using to create a Bill)
Step 2- Make a second call to update the SubcontractNbr using the post API call.

We can't do both at a time.

I created new subcontract. but I still got this error 

 

Userlevel 7
Badge +11

Did you follow the below steps?

  • Create a Bill using PUT call.
  • Create a subcontract 
     
  • Make sure on the bills and adjustment screen, your newly created subcontact showing on the AddSubcontractline popup like below

    - Make a POST call to update the bill with the newly created sub-contract.


     
Userlevel 4
Badge +2

Did you follow the below steps?

  • Create a Bill using PUT call.
  • Create a subcontract 
     
  • Make sure on the bills and adjustment screen, your newly created subcontact showing on the AddSubcontractline popup like below

    - Make a POST call to update the bill with the newly created sub-contract.


     

I found strange behavior

I do know why, but my Bills are created with “Closed state”. How to fix that ?

Here is my request 

{

  "VendorRef": {

    "value": "123421"

  },

  "DueDate": {

    "value": "3/2/2023"

  },

  "Vendor": {

    "value": "V-02072"

  },

  "Date": {

    "value": "1/31/2023"

  },

  "Terms": {

    "value": "PWP"

  },

  "PostPeriod": {

    "value": "01-2023"

  },

  "Details": [

    {

      "Description": {

        "value": "Line 001 - Gypcrete"

      },

      "Qty": {

        "value": 1000

      },

      "UnitCost": {

        "value": "34573.2"

      },

      "ExtendedCost": {

        "value": "34573.2"

      },

      "Account": {

        "value": "5430"

      },

      "rowNumber": {

        "value": "1"

      }

    }

  ]

}

 

Userlevel 4
Badge +2

Did you follow the below steps?

  • Create a Bill using PUT call.
  • Create a subcontract 
     
  • Make sure on the bills and adjustment screen, your newly created subcontact showing on the AddSubcontractline popup like below

    - Make a POST call to update the bill with the newly created sub-contract.


     

There is also problem with 3 step that you have advised : “Make sure on the bills and adjustment screen, your newly created subcontact showing on the AddSubcontractline popup like below

I tried to create new subcontract + tries to select the existing one but none of them is depicted it this section

 

Userlevel 7
Badge +11

I used the below request (PUT Method) to create a Bill without line details. When we make another request to add the subcontract details, the line details will add automatically

{
"VendorRef": {
"value": "123421"
},
"DueDate": {
"value": "3/2/2023"
},
"Vendor": {
"value": "PLUMBING"
},
"Terms": {
"value": "30D"
}
}


Please make sure the same vendor you are using creates Bills and subcontracts. The subcontract should be open status.

Userlevel 4
Badge +2

I used the below request (PUT Method) to create a Bill without line details. When we make another request to add the subcontract details, the line details will add automatically

{
"VendorRef": {
"value": "123421"
},
"DueDate": {
"value": "3/2/2023"
},
"Vendor": {
"value": "PLUMBING"
},
"Terms": {
"value": "30D"
}
}


Please make sure the same vendor you are using creates Bills and subcontracts. The subcontract should be open status.

I got a problem, without no reason it is created with closed state 

Here is my request

{

  "VendorRef": {

    "value": "12343521"

  },

   "Hold": {

        "value": true

    },

  "DueDate": {

    "value": "3/2/2023"

  },

  "Vendor": {

    "value": "V-02072"

  },

  "Date": {

    "value": "1/31/2023"

  },

  "Terms": {

    "value": "PWP"

  },

  "PostPeriod": {

    "value": "01-2023"

  }

  

  

}

Userlevel 4
Badge +2

I used the below request (PUT Method) to create a Bill without line details. When we make another request to add the subcontract details, the line details will add automatically

{
"VendorRef": {
"value": "123421"
},
"DueDate": {
"value": "3/2/2023"
},
"Vendor": {
"value": "PLUMBING"
},
"Terms": {
"value": "30D"
}
}


Please make sure the same vendor you are using creates Bills and subcontracts. The subcontract should be open status.

Currently I have 2 problems :

  1. as you suggested

    Make sure on the bills and adjustment screen, your newly created subcontact showing on the AddSubcontractline popup like below

    I tried to create new subcontract + tries to select the existing one but none of them is depicted it this section

    1. I do not know why, but all bills are created with “closed” 

      Here is my request 

      {

        "VendorRef": {

          "value": "12343521"

        },

         "Hold": {

              "value": true

          },

        "DueDate": {

          "value": "3/2/2023"

        },

        "Vendor": {

          "value": "V-02072"

        },

        "Date": {

          "value": "1/31/2023"

        },

        "Terms": {

          "value": "PWP"

        },

        "PostPeriod": {

          "value": "01-2023"

        }

        

        

      }

Userlevel 7
Badge +11

Hi @Ivan 

Am not sure the reason why the bills were created with closed status. You can check with different vendors and try.

Userlevel 4
Badge +2

Hi @Ivan 

Am not sure the reason why the bills were created with closed status. You can check with different vendors and try.

Ok, but what I should do with this - 

as you suggested
“Make sure on the bills and adjustment screen, your newly created subcontract showing on the AddSubcontractline popup like below”

I tried to create new subcontract + tries to select the existing one but none of them is depicted it this section

Userlevel 4
Badge +2

Hi @Ivan 

Am not sure the reason why the bills were created with closed status. You can check with different vendors and try.

Hi @jinin 

Can you suggest how to resolve this - 

as you suggested
“Make sure on the bills and adjustment screen, your newly created subcontract showing on the AddSubcontractline popup like below”

I tried to create new subcontract and tried to select the existing one subcontract but none of them is depicted at this section. What should I check ?

Userlevel 7
Badge +11

Hi @Ivan ,

I’ve created a subcontract like below,


I can able to get the subcontract details on the AP Bill screen
 


Not sure why you are not getting the details.  ​​​​​​​

Reply


About Acumatica ERP system
Acumatica Cloud ERP provides the best business management solution for transforming your company to thrive in the new digital economy. Built on a future-proof platform with open architecture for rapid integrations, scalability, and ease of use, Acumatica delivers unparalleled value to small and midmarket organizations. Connected Business. Delivered.
© 2008 — 2024  Acumatica, Inc. All rights reserved