- All Categories
- 73 General
- 73 Announcements
- 66.5K Microsoft Dynamics NAV
- 18.6K NAV Three Tier
- 38.4K NAV/Navision Classic Client
- 3.6K Navision Attain
- 2.4K Navision Financials
- 115 Navision DOS
- 854 Navision e-Commerce
- 1K NAV Tips & Tricks
- 772 NAV Dutch speaking only
- 615 NAV Courses, Exams & Certification
- 2K Microsoft Dynamics-Other
- 1.5K Dynamics AX
- 287 Dynamics CRM
- 109 Dynamics GP
- 10 Dynamics SL
- 1.5K Other
- 993 SQL General
- 384 SQL Performance
- 34 SQL Tips & Tricks
- 34 Design Patterns (General & Best Practices)
- Architectural Patterns
- 10 Design Patterns
- 5 Implementation Patterns
- 53 3rd Party Products, Services & Events
- 1.7K General
- 1.1K General Chat
- 1.6K Website
- 79 Testing
- 1.2K Download section
- 23 How Tos section
- 259 Feedback
- 12 NAV TechDays 2013 Sessions
- 13 NAV TechDays 2012 Sessions

Options

Kim
Member Posts: **85**

Hi, Am having some trouble converting data types. am working on a payroll

where am supposed to use formulas. for example:**strformula:='((([BPAY]/20)/8)*1.5)*[P003]'**;

Am holding the formula first on a Text Variable because the value of**BPAY** and **P003** can vary from employee to

another.

Am stuck in trying to convert the text variable** strFormula** to Decimal so i can insert the formula to a decimal field.

any one got an idea how i can do this.

:?:

where am supposed to use formulas. for example:

Am holding the formula first on a Text Variable because the value of

another.

Am stuck in trying to convert the text variable

any one got an idea how i can do this.

:?:

0

## Comments

68885Type conversion is not possible because one of the operators contain an invalid type

621easier way is to change your code

strformula:='((([BPAY]/20)/8)*1.5)*[P003]';

to

strformula:='(((%1/20)/8)*1.5)*%2';

and then use

formula := STRSUBSTNO(strformula, BPAY, P003);

and then use EVALUATE function to obtain final result.

688Did you check the content of strformula via debugger or a message?

85thanks

let me try this

85if i try to use the EVALUATE function this way:

EVALUATE(finalformula,strformula);finalformulais a decimal variableam getting

an

error [You cannot insert "(((100/20)/8)*1.5)*110"] in decimal]](*,)

85Some values in payroll are as a result of calculation formulas provided for by the Revenue authorities

or any other body for example. VALUE:='(((BASICPAY/20)/8)*1.5)*NOOFHRS'

for my case i intent to handle them from setup since from previous experience they have proved to be

enough problems if done within the code.

Has anyone handled such kind of formulas and how did u go about it???

688The error is clear and your posts show that you may be lacking on basic knowledge of datatypes. You simply cannot put a string into a decimal field, period!

6881,59885Thanks had not thought of that functionality in codeunit 8

:whistle: