I have kept a button on the menu items of service order page as "purchase order". Now by clicking the purchase order button purchase order page should open by having the service order no in a lookup field which I have created.
It's not so clear if you want to create a Purchase Order by passing your field to the header or if you want to "lookup" a purchase order.
If you want to create a purchase order, on the OnAction (click of your button):
1) Create the Purchase Header with your custom field initialized
2) Open the purchase order card by passing the Purchase Header created:
If you want a lookup:
On the OnAction of your button, you've to:
1) retrieve the purchase order accordingly to your needs (apply correct filters)
2) Pass the purchase order to the Purchase Order Page
You can write something like:
PurchaseHeader.SETRANGE(...); //Here you apply your filters to retrieve the record
IF pgPurchaseOrderList..RUNMODAL = ACTION::LookupOK THEN
Actually on a service order page I customized a button and that button on onlcik should open new purchase order page with the service order number mapped in a customized lookup field. Service order number should get from the current page where the button is kept.
Ok, so the first part of my previous response.
On your click of the button, create a new Purchase Header with the fields you want populated, then open the Purchase Order Card page as described.
I can able to open a new purchase order by clicking the button through run page link property but i want to know how to populate service order no to my new customized filed in po page
No, you' don't have to open the page via the RunPageLink. You have to handle it via code because (as previously described):
1) you have to create the Purchase Header filled with your fields
2) After the creation, you have to open the Purchase Order card with the created record in input.
I entered the following code but it doesn't work
PurchaseHeader.SETRANGE("Document Type",PurchaseHeader."Document Type"::Order);
PurchaseHeader.SETRANGE("Service Order No.",PurchaseHeader."Service Order No.");
PurchaseHeader."Service Order No.":=Rec."No.";
here PurchaseHeader is recordset and purchaseorder is page.
This code is wrong, line 4 has no sense.
If on the click of your button you want to create a Purchase Header and fill the "Service Order No." field with your Service Order value, you've to do something like this:
PurchaseHeader."Document Type" := PurchaseHeader."Document Type"::Order;
PurchaseHeader.VALIDATE("Buy-from Vendor No.",YOURVENDOR);
PurchaseHeader."Service Order No." := Rec."No.";
//Here you've create the Purchase Order
//Now you open the Purchase Order Card with the created record
Thank you very much Stefano....
can you please share the code
As i checked through debugger It executes correctly before the last line of the code
CLEAR(PurchaseHeader); PurchaseHeader.INIT; PurchaseHeader."Document Type" := PurchaseHeader."Document Type"::Order; PurchaseHeader.INSERT(TRUE); PurchaseHeader."Service Order No." := ServHeader."No."; PurchaseHeader.MODIFY(TRUE); PurchaseOrder.SETRECORD(PurchaseHeader); PurchaseOrder.RUNMODAL;
But for the last line "PurchaseOrder.RUNMODAL;" a error throws that is " The following C/AL functions are limited during write transactions because one or more tables will be locked. Form.RunModal is not allowed in write transactions. codeunit.run is used in write transaction onl if the return vlueis not used.
Now it working after replacing the code for PurchaseOrder.RunModal; as PAGE.RUN(PAGE::"Purchase Order",PurchaseHeader); Thanks
I'm doing same thing like sending record from custom page to sales Invoice. But on sales invoice ,lookup for customer is not working, as I'm sending 'Customer No.'
and other question How can I send line items. Please help me out. your help would be appreciated. Thanks.
My code is
I found the solution. Thanks.
Is there a way to open a purchase order page in create mode and pass service order no. to it? Then on purchase order page we can get that service order no. and can then fill out the lookup field for service order no.
Business Applications communities