AugForums.com

An Acumatica User Group

  • Free
    • Start Here
    • Rolodex
    • Podcast
    • Blog
    • Forums
  • Paid
    • AugSQL
    • GI Course
    • GI Library
    • Consulting
  • Register
Acumatica Forums

By using this website, you agree to our Terms of Use (click here)

Forums
AUG Forums
Acumatica Generic I...
Conversion failed w...
 
Notifications
Clear all

Questions Conversion failed when converting the varchar value 'ONLINE DISCOUNT' to data type int

 
Acumatica Generic Inquiries & Pivot Tables
Last Post by Rob Cushen 6 years ago
6 Posts
3 Users
2 Reactions
5,037 Views
RSS
Rob Cushen
Posts: 24
 Rob Cushen
Topic starter
July 22, 2019 5:32 pm
(@robcushen)
Eminent Member
Joined: 6 years ago

Hi,

Using the formula =IIf( [ARTran.InventoryID] = 'ONLINE DISCOUNT', [ARTran.Qty]*-1, [ARTran.Qty]) causes the error "Conversion failed when converting the varchar value 'ONLINE DISCOUNT' to data type int".    How do I get around this?

Thanks!


5 Replies
Brandon
Posts: 26
 Brandon
July 23, 2019 1:12 am
(@brandon)
Member
Joined: 7 years ago

I believe you need to use the InventoryCD field rather than InventoryID. The InventoryID is an integer assigned internally by the system so it is giving an error when you are trying to match it to the text string 'ONLINE Discount'. I believe there are two solutions you could use in this case. 

The first would be to add the InventoryItem table to your GI and then join the ARTran table to the InventoryItem table through the InventoryID. You can then update your formula to say if the InventoryItem .InventoryCD = 'ONLINE DISCOUNT'.

The other option would be to lookup what the internal InventoryID is and then just update your formula so that it is equal to this value rather than 'ONLINE DISCOUNT'.


Reply
Rob Cushen
 Rob Cushen
(@robcushen)
Joined: 6 years ago

Eminent Member
Posts: 24
July 23, 2019 3:39 pm
Reply toBrandonBrandon

@brandon

Thanks for the response Brandon...  I employed this method -> "The first would be to add the InventoryItem table to your GI and then join the ARTran table to the InventoryItem table through the InventoryID. You can then update your formula to say if the InventoryItem .InventoryCD = 'ONLINE DISCOUNT'."

I am somewhat new to Acumatica and having some issues with the naming and display conventions... oddly enough when the ARTran.InventoryID is used with non-integer values in the conditions section it works with no errors.


Reply
Royce Lithgo
Posts: 557
 Royce Lithgo
July 23, 2019 2:56 pm
(@roycelithgo)
Honorable Member
Joined: 6 years ago

Please do it the proper way, as per Brandon's first option. Using internal Id fields in queries is just asking for trouble and not user friendly either.


Reply
Royce Lithgo
Posts: 557
 Royce Lithgo
July 23, 2019 4:23 pm
(@roycelithgo)
Honorable Member
Joined: 6 years ago

Acumatica does some behind the scenes magic to map CD text values to ID internal numeric values when you directly reference a field in GI, whether it be in conditions or results. However this doesn't work if you try to use an ID field directly in a formula as you did. The field needs to be selected from the Data Field dropdown (and not entered as a formula).

If you use the ID field in a condition, you can also click the From Schema option and then select the value from a list. This is much more user friendly as you can directly see the selected CD value in your query criteria rather than and ID value which would be meaningless. If after selecting a value with the From Schema option enabled you untick From Schema, you will then see the internal ID value in the query criteria. This is an easy way to lookup ID values in queries if you need to. 


Reply
Brandon reacted
Rob Cushen
 Rob Cushen
(@robcushen)
Joined: 6 years ago

Eminent Member
Posts: 24
July 23, 2019 4:28 pm
Reply toRoyce LithgoRoyce Lithgo

@royce-lithgo

Thanks for the clarification Royce.


Reply
Tim Rodman reacted
Forum Jump:
  Previous Topic
Next Topic  
Forum Information
Recent Posts
Unread Posts
Tags
  • 12 Forums
  • 2,526 Topics
  • 10.9 K Posts
  • 17 Online
  • 2,411 Members
Our newest member: thollings
Latest Post: Customer Portal Setup - Access issues to create sales order
Forum Icons: Forum contains no unread posts Forum contains unread posts
Topic Icons: Not Replied Replied Active Hot Sticky Unapproved Solved Private Closed

Online Members

 No online members at the moment

Acumatica Forums

Terms of Use & Disclaimers :: Privacy Policy

Copyright © 2025 · AUG Forums, LLC. All rights reserved. This website is not owned, affiliated with, or endorsed by Acumatica, Inc.

‹›×

    ‹›×