Solved

Using a UDF as a selector that stores the ID of a record from another table

  • 16 June 2021
  • 3 replies
  • 255 views

Userlevel 6
Badge +3

I created a UDF for the Journal Transactions screen.  It is a selector that pulls from a custom table.  The ID of the value from the custom table is supposed to be stored in the UDF.

When you create a new JE, the lookup works great!

After selecting:

So far so good.  The problem is that when the RowSelected fires, the value is cleared from the field.

 

There is one record in the custom table with an ID of 1.  If I edit the Batch table and put a 1 in the UDF, and then go to that JE, the screen shows a “1”.  It should show “TEST1 - Test 1” which would be what would show if you actually selected something.  

When creating a new JE, I selected the TEST1 from the selector.  When I go to add a line item to the grid, the RowSelected handler fires.  I put a little code in the handler to see if there is a value in that field:

In the RowSelected event for the batch, the itemExt.UsrProjectID is null.

The only thing I have to work from is the Acumatica Training code and there isn’t an example of adding a UDF as a Selector.  I’m stuck.

So this is really two issues.

  1. How do I get the selected value in the Selector to save to the UDF field in the Batch table
  2. If a UsrProjectID value IS in the Batch record, how do I display it as the value would show if it was selected rather than by it’s ID value (1 in this case).

Any help is greatly appreciated.

Thanks!

Joe

 

icon

Best answer by jknauf 17 June 2021, 15:48

View original

3 replies

Userlevel 3
Badge

Hey there Joe,

I think your issue is your selector is looking for and trying to store the value of the CD. You want the selector to store the value of the ID, but display the CD. That’s what the substitute key is for, which you have correct.

So I’d say try changing your selector to:

[PXSelector(typeof(Search<ICExtProjects.projectID>),
...

And everything after that looks good. Let me know how this works for you!

Userlevel 7
Badge +17

Yes, I agree with @jknauf..

In DAC field, you are searching for CD and given datatype as Integer.. this is the issue… and that is why field is getting clear after your selected the value

You should search of ID in DAC field.

Also, after your save, ID value will be inserted into the Batch table.

Userlevel 6
Badge +3

jknauf, that did the trick.  OMG.  For a while there, I thought I was going to have to do on-the-fly conversions of the field in the various events.  I hoped I was doing something wrong and it was a simple thing.  It was!

Thanks jknauf!  Also, thank you Naveen!

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