Workflow Soluiton

 View Only
  • 1.  Negative Numbers

    Posted Nov 12, 2014 01:19 PM

    We have a workflow that looks into a table finds out what level a price should be at then finds the price for that item. Some of these items are negatives. I was using the ABS value for the price but it can't handle negatives. What other option do I have that can give me a number that is a negative? Tried a merge text as well as a number formatter and it just explodes the process.

     

    Thanks



  • 2.  RE: Negative Numbers

    Posted Nov 12, 2014 01:25 PM

    Can you give more info on what you're trying to do with the number once you've fetched it?  If you're trying to display it in a label, textbox, etc?



  • 3.  RE: Negative Numbers

    Posted Nov 12, 2014 01:29 PM

    It is an ajax lable on a webform. So the user picks an item from the table, They can then enter a qty and the ajax label goes and grabs the price based on the level the customer is at. It then returns it to the webform to show the price. the user can hit calculate and it will give them the price qty x price. 

     

    Capture1 shows the process in the ajax lable. Dont worry about the merge text called signature.

    Capture2 shows where the result of the ajax lable is displayed to the customer.

     

    Hope that makes sense.



  • 4.  RE: Negative Numbers

    Posted Nov 12, 2014 01:43 PM

    And the price value may sometimes be negative?  If you're just looking to multiply values, the multiply values component should be fine.  The output of that component should suffice for the endpoint in an ajax label.

    If you're doing some text merging, keep in mind you can drop down and select a format, whether it's currency or number:

    2014-11-12_11-37-12.png 

    I guess technically you could use the Multiply Values component and multiply the negative number variable by "-1", and you should get the positive version.  If you then want to display it as currency, use the method I indicated above in a merge text inside the ajax label.

    2014-11-12_11-42-11.png

    If you're initially fetching the data from a SQL table, you could use the ABS function (assuming you never want to return a negative value).  This would preclude any adjustments in Workflow for negative values.

    http://msdn.microsoft.com/en-us/library/ms189800.aspx

    I could probably give a better response if I went through your process a bit.  let me know if you want to do a quick webex and have a look.



  • 5.  RE: Negative Numbers

    Posted Nov 12, 2014 03:06 PM

    We are pulling a negative value from Sql. If the user is at a high enough level its a credit so sql holds a -43 vs 43 for someone else. So the ABS will not work as that is what we tried since it makes all the values +. 

    Essentially we need to be able to pull the - value from sql and send it out the other side. 



  • 6.  RE: Negative Numbers

    Posted Nov 13, 2014 02:37 PM

    You can modify your SQL query that is fetching the data. Just use ABS in the query:

    select ABS(-1.0)

    OK, not useful after reading more carefully.

    You could do something like this:

    declare @cost smallmoney = -1.0
    select case
    when charindex('-', cast(@cost as varchar(15))) = 1
    then '-'
    else '+'
    end as [polarity],
    SUBSTRING(cast(@cost as varchar(15)), charindex('-', cast(@cost as varchar(15))) + 1, 15) as [cost]

    You could then use the [polarity] column to drive the logic your your code.



  • 7.  RE: Negative Numbers
    Best Answer

    Posted Nov 13, 2014 03:44 PM

    I was able to use the get number from string filed and then load it into a merge text that was set to currancy and it worked perfectly.