cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Nathorius
Regular Visitor

Invalid number of arguments with a patch to Business Central

Hi all,

 

I am creating an app based on the Sales Quote of Business Central, where I want to change the Unit Price of the Sales Line from a Powerapps value.

 

In Postman and in the Custom Connector test I am able to make the patch correctly. Here is the Swagger:

 

 

 

 

/api/xperit/production/v1.0/companies({companyid})/SalesPricing(docType='{docType}',number='{number}',lineNo={lineNo}):
    patch:
      responses:
        default:
          description: default
          schema: {}
      summary: Patch Test
      operationId: PatchSalesLine
      parameters:
      - {name: companyid, in: path, required: true, type: string}
      - {name: docType, in: path, required: true, type: string, format: ''}
      - {name: number, in: path, required: true, type: string, format: ''}
      - {name: lineNo, in: path, required: true, type: string}
      - {name: If-Match, in: header, required: false, type: string}
      - {name: Content-Type, in: header, required: false, type: string}
      - name: body
        in: body
        required: false
        schema:
          type: object
          properties:
            unitPrice: {type: integer, format: int32, description: unitPrice}
definitions: {}

 

 

 

 

However, from Powerapps, not. It should work from a collection, but to get it working I created a specific page first with labels with al the values I need. It looks promising but it keeps saying "Invalid number of arguments, received 1, expected 2 or more".

This is the patch:

 

 

 

Patch(BusinessCentral.PatchSalesLine(CurrentCompanyId,DocType.Text,QuoteNo.Text,LineNo.Text,{'If-Match':Etag.Text,unitPrice:UnitPrice.Text}))

 

 

 

 

I hope it's just a missing bracket orso. Does someone have an idea?

 

Best,Geert

1 ACCEPTED SOLUTION

Accepted Solutions
Nathorius
Regular Visitor

Solution found. The way I created the function resulted in a double patch, since the Custom Connector is a patch itself. This works:

ForAll(QuoteLines.AllItems,
  BusinessCentral.PatchSalesLine(CurrentCompanyId, "Quote", Lbl_QuoteNo.Text, Lbl_LineNo.Text, {'If-Match':"*", unitPrice:UnitPriceNew.Text})
);

View solution in original post

1 REPLY 1
Nathorius
Regular Visitor

Solution found. The way I created the function resulted in a double patch, since the Custom Connector is a patch itself. This works:

ForAll(QuoteLines.AllItems,
  BusinessCentral.PatchSalesLine(CurrentCompanyId, "Quote", Lbl_QuoteNo.Text, Lbl_LineNo.Text, {'If-Match':"*", unitPrice:UnitPriceNew.Text})
);

View solution in original post

Helpful resources

Announcements
PA_User Group Leader_768x460.jpg

Manage your user group events

Check out the News & Announcements to learn more.

Power Query PA Forum 768x460.png

Check it out!

Did you know that you can visit the Power Query Forum in Power BI and now Power Apps

Carousel 2021 Release Wave 2 Plan 768x460.jpg

2021 Release Wave 2 Plan

Power Platform release plan for the 2021 release wave 2 describes all new features releasing from October 2021 through March 2022.

R2 (Green) 768 x 460px.png

Microsoft Dynamics 365 & Power Platform User Professionals

DynamicsCon is a FREE, 4 half-day virtual learning experience for 11,000+ Microsoft Business Application users and professionals.

Users online (1,268)