How to validate against item master table - openedge

I am creating a custom report screen in which I have a fields item number, item type, prod line and status and there is a condition for item number that is I have to validate it against pt_mstr which from what i understand means that the item number that I enter should be present in pt_mstr. And if it's blank then give an error. I've done the validation for blank with this code
If lvc_part = "" then do:
{us/bbi/pxmsg.i &msgnum=40 &errorlevel=3}
Undo mainloop, retry mainloop.
End.
Lvc_part is the variable i declared for item number and mainloop is the loop inside which I'm writing my entire logic. I am getting the general idea for validating item number against pt_mstr but I'm not getting how to put it down as a code. I'm thinking we need to include a find first query to see if the item number is present in pt_mstr or not but I'm not sure. Any leads would be helpful, if you want to know anything regarding the declarations I've used or anything else let me know. Thanks in advance!

You need to add code like this
IF NOT CAN-FIND (FIRST pt_mstr WHERE pt_mstr.<keyfieldname> = lvc_part) THEN
<display error message>
or when it's a index with multiple fields:
IF NOT CAN-FIND (FIRST pt_mstr WHERE pt_mstr.<keyfieldname1> = lvc_part
AND pt_mstr.<keyfieldname2> = <value>) THEN
<display error message>
Most likely you can (and should) leave out the FIRST phrase in the CAN-FIND expression as typically you'd be using a UNIQUE find here.

Related

How can I prevent a Netsuite custom field formula from displaying an error caused by a (temporarily) missing field?

I want to display the quantity remaining (qty ordered less qty fulfilled) on the lines of a sales order. I'm using the suggestion here:
http://www.netsuiterp.com/2018/09/add-quantity-remaining-column-on-sales.html
with a small tweak of the formula to exclude closed lines (case when {isclosed} <> 'T' then {quantity}-{quantityfulfilled} else 0 end).
The problem I'm having is that though it works perfectly for sales orders once they've been saved, when a user is creating a new sales order this field displays an error apparently because one of the fields referenced in my formula doesn't exist yet for that transaction. Usually it is "ERROR: Field 'quantityfulfilled' Not Found". I've tried adding some null-value handling to my formula, like adding
and nvl({quantityfulfilled},'') <> ''
to the 'when' condition, but I'm guessing the absence of the field is different from a null value since the error is unaffected. This is distracting and confusing to users. Is there a way to prevent it from displaying?
in scripts checking on internal id can be used as a test for a new record so:
case when {internalid} is null then 0 when {isclosed} = 'T' then 0 else {quantity}-{quantityfulfilled} end

check duplicate values in oracle forms multi record block

What I wanted is to display an alert when I move to the next row if the record that I inserted is already one of the records in the multi record block.
and in what trigger must I put it?
There are several options you can use.
One is to POST values entered (in WHEN-NEW-RECORD-INSTANCE) trigger. It will, well, post everything you entered so far. Then, you can write a WHEN-VALIDATE-ITEM trigger which SELECTs from that table and checks whether such a value already exists. Alternatively, if there's the UNIQUE CONSTRAINT on that (those) column(s), database will do its job itself, i.e. raise an exception.
Another option is to literally loop through all rows in a block and compare the first row's value with all the others, then the second row's values with all of them, etc.
Or, you can use a Record Group (usually used for Lists of Values). Basically, you'd check whether value you entered exists in a record group. More info, along with a FMB file, on Craig's blog.
Or, you can use calculated items, as described enter link description here (FMB attached as well).
As you can see, quite a few ways to do that; explore each of them and pick the one you find the most useful / attractive / easy to implement.

Foreach inside asp.net mvc5 view

I'm in need of a little help in here . I'm getting results that come from virtual property , but one row displays in multiple rows in view. How to display a record inside a row , and not in multiple records
#foreach (var item in Model.Event.Id)
appears to be your problem. You're looping over the event ID, which since it's a string, will be treated like an array of characters. Therefore it prints one character from the ID on each line, and then, because of the rest of the code, repeats all the other details of that event on each line.
Since you only appear to have one single Event in your Model, it seems that you do not need any kind of loop here at all.
However it's not entirely clear what your intentions are - perhaps you intended to loop over something else in your model which is not shown. If so, please clarify the question and possibly the answer could be expanded.

Table input for view

I would like to have the user enter order items on my order form as a table where they input the Qty and Prod #. I've not programmed with that type of field so a blank line would initially display for a new order. They would type a Qty and an item number in the fields and hit enter. When they hit enter from either field, what do I program to check the validity of the two fields. Plus I need the item number to be a drop down/type ahead field. Does anyone have an example of this type of thing they could send me? It would be looking at a view in the product catalog db. Also, after they enter an item to order, that "doc" should get stored/saved and a new blank line should open up.
What type of control do I need to use and should these items be stored in their own form or on the main order document? Could use some guidance here. Thanks.
The question you have is a little broad but I will make a couple suggestions if I can.
You have the main order doc. Then a repeat control with each item. Filter each item by a uniqueID that allows you to join the main doc to the child docs. Each item should be a separate document. You then need to make the items in the repeat control editable.
There is a lot of things going on here and I think you need to get started somewhere. I think the first step is to do a repeat control with response documents.Xpages, Inherited documents in view panel by using #Unique

AX 2009: Report Range on enums parsing enum value commas?

I think I may have found an interesting bug with AX 2009, and I'm unsure of how I can proceed.
I am attempting to write a new report, and one of the conditions of this report is to be filtered based on the Posting field of the LedgerTrans table. However, it seems that when the report goes to execute, the label of the enum Purchase, receipt is parsed without regard to the quotes. This normally wouldn't be a problem, but the enum label in this case contains a comma. The result is that when run the query dialog box reads: Purchase, consumption, __ILLEGAL_VALUE__. I get this result even if I use the enum value or name. The report must be left interactive, but this field must be locked, so we cannot get the users to adjust the query at run time.
At this point I don't want to change the label itself, but if it is the only way to solve this I will. Has anyone else run into this, or know how we could overcome it?
I've run into this before. Sometimes an acceptable option is hard-coding the conditional values as an OR statement, rather than the comma separated list:
((LedgerTrans.Posting == LedgerPostingType::PurchReceipt) || (LedgerTrans.Posting == LedgerPostingType::PurchConsump))
That can be typed into a range filter box, or can be set as the value of a range via x++ code:
ledgerPostingRange.value("((LedgerTrans.Posting == LedgerPostingType::PurchReceipt) ||
(LedgerTrans.Posting == LedgerPostingType::PurchConsump))");
AX doesn't try to convert these to the labels, so they stay as distinct values, instead of being rendered as labels. Note that parentheses are required for it to be parsed properly.
Since the ILLEGAL_VALUE can appear even when attempting to use a single value that contains a comma in its label, the same can be done for a single :
ledgerPostingRange.value("(LedgerTrans.Posting == LedgerPostingType::PurchReceipt)");
I would definitely change the label! But as a workaround you could use the enum value's number instead.
If the field is often queried, you could put the field in a dialog then change the query:
ledgerPostingRange.value(ledgerPostingType ? int2str(ledgerPostingType) : '');

Resources