Skip to main content
Solved

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


Joe Schmucker
Captain II
Forum|alt.badge.img+2

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

 

Best answer by jknauf

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!

View original
Did this topic help you find an answer to your question?

Forum|alt.badge.img
  • Varsity II
  • June 17, 2021

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!


Naveen Boga
Captain II
Forum|alt.badge.img+19

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.


Joe Schmucker
Captain II
Forum|alt.badge.img+2

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


Cookie policy

We use cookies to enhance and personalize your experience. If you accept you agree to our full cookie policy. Learn more about our cookies.

 
Cookie settings