Skip to main content
Solved

Custom Field: expiration date

  • December 2, 2024
  • 7 replies
  • 199 views

Forum|alt.badge.img+5

Hi,

Is it possible to build a custom field for the Inventory Part In Stock table that shows how many days we have before the expiration?

I’ve been trying to build a read only field, as a select statement, even though I’m able to save the custom field I cannot validate it.

here are my SQL, image of the Custom and Image of error

SELECT a.expiration_date, TRUNC(a.expiration_date) - TRUNC(SYSDATE) AS CF$_DAYS_TO_EXPIRE
FROM inventory_part_in_stock a
WHERE a.LOT_BATCH_NO = :LOT_BATCH_NO AND a.expiration_date IS NOT NULL;
 

 

Best answer by MHRDonato

Hello,

 

I had my SQL sentence fixed and it worked.

Here is the new SQL, if anyone would like to implement:
 

SELECT TRUNC(a.expiration_date) - TRUNC(SYSDATE)

FROM inventory_part_in_stock a

WHERE a.LOT_BATCH_NO = :LOT_BATCH_NO AND a.expiration_date IS NOT NULL

I had to do an extra change from ​@kvbe ‘s SQL

 

 

Thank you for the help.

All the best
Murilo.​​​​​​​

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

7 replies

Forum|alt.badge.img+10
  • Hero (Partner)
  • 207 replies
  • December 2, 2024

@MHRDonato your query is incorrect as it should only return one value (now it returns two). Besides that its the result of the query that gets shown into the custom field so no need for the AS clause. 

So I think this should be more correct 

SELECT TRUNC(a.expiration_date) - TRUNC(SYSDATE)

FROM ifsapp.inventory_part_in_stock a

WHERE a.LOT_BATCH_NO = :LOT_BATCH_NO AND a.expiration_date IS NOT NULL


no ; is needed either.

 

Good luck!

 

Forum|alt.badge.img+5
  • Author
  • Sidekick (Customer)
  • 13 replies
  • December 2, 2024

@kvbe , thank you for your response.


The new SQL Statement worked, now it does validate the SQL, however It show’s a new message, I tried to publish aiming to see the possible error, and it shows the following error.

 

 


matt.watters
Superhero (Partner)
Forum|alt.badge.img+26
  • Superhero (Partner)
  • 659 replies
  • December 3, 2024

I saw something similar at a customer, and I recall the solution required a persistent custom field and a scheduled database task to run once daily to calculate the value and insert/update it in this field.


Michael Kaiser
Sidekick (Customer)
Forum|alt.badge.img+9
  • Sidekick (Customer)
  • 108 replies
  • December 3, 2024

Hi,
just want to thank you for a new idea!
 

FACT_InventoryPartInStock
We take that from a Delta-Table where every night the plus/minus for every part will go into.
 

In the MS SQL DWH we take a snapshot every night.

 

Hope that brings new ideas to every reader.
All the best.

Michael
 


Forum|alt.badge.img+5
  • Author
  • Sidekick (Customer)
  • 13 replies
  • Answer
  • December 3, 2024

Hello,

 

I had my SQL sentence fixed and it worked.

Here is the new SQL, if anyone would like to implement:
 

SELECT TRUNC(a.expiration_date) - TRUNC(SYSDATE)

FROM inventory_part_in_stock a

WHERE a.LOT_BATCH_NO = :LOT_BATCH_NO AND a.expiration_date IS NOT NULL

I had to do an extra change from ​@kvbe ‘s SQL

 

 

Thank you for the help.

All the best
Murilo.​​​​​​​


matt.watters
Superhero (Partner)
Forum|alt.badge.img+26
  • Superhero (Partner)
  • 659 replies
  • December 3, 2024

@MHRDonato could you show the Implementation Type page of the custom field definition where you have the Arguments and Select Statement?


Forum|alt.badge.img+5
  • Author
  • Sidekick (Customer)
  • 13 replies
  • December 3, 2024

@matt.watters yes, here it is.

Also, do you know if the Method Signature below is the information that I have to input at Server Method (PL/SQL function) while creating a custom event?
 

 


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