Jump to content


Photo

Lineitems page need to add calculation

staff response

  • Please log in to reply
5 replies to this topic

#1 vijayviswa

vijayviswa

    Member

  • Members
  • PipPip
  • 13 posts

Posted 22 May 2017 - 12:01 AM

I want to add more field in line items box .Now It's working in sum of these three things(unit price*quantity+adjustment) total value display in Total as per calculation. Now i want to use this total value into another calculation for ex:- one drop down will display with these things (+,-,*,%) and one more field i will enter my amount on that text box when i select the drop down into (-) means it will take my new field value to this format (Total amount  value- New field value).and then it will reflect in that total amount. Similarly, the total should change based on the arithmetic operators mentioned in the drop down box.

Because your line items functionality is pretty good to use but except this line items only don't have dynamic fields adding method. If suppose this feature will be available on that page means it will be very useful 

is there any possibility to perform math operations like add,etc with the calculated field with other field(user typed) ?



#2 X2Raymond

X2Raymond

    Advanced Member

  • Administrators
  • 972 posts
  • LocationSanta Cruz, CA

Posted 22 May 2017 - 01:46 PM

With formula fields, you unfortunately cannot yet reference other formula fields. This means that if you want to do so, you'll need to actually unpack the nested formula into your outer formula for the full calculation.

 

If you are trying to add this new offset field to be applied per line item, then you will unfortunately be required to write some custom code to do so. You should be able to do it on a per-quote level by using workflow on a record updated trigger though. You'll want to add two new decimal fields, offset and new total in the screenshots below, and a new dropdown field to contain your operations. You will also need to modify your Quote form layout to display the new fields. Also, be sure to update your references to the quote total within your templates to use the new calculated total, e.g., {c_newTotal}.

 

Then, construct a workflow on record update, which checks the operation against your known values. On each record update action after the condition, set your new total field using the selected operation.

Attached File  totalUpdateWF.png   53.91KB   4 downloads

 

Upon setting your operation and offset, then saving the form, the new total will be updated according to your workflow rules:

Attached File  updateTotalForm.png   12.96KB   3 downloads



#3 vijayviswa

vijayviswa

    Member

  • Members
  • PipPip
  • 13 posts

Posted 24 May 2017 - 04:03 AM

Hi Raymond,

 

Thanks for your reply..

 

Now i have added the work flow as per your screen shots guidance.you have mentioned  write some custom code to view the new total value.The work flow affected some records and  i can can get the link using  "show trigger log" on that top link in work flow page but it will not show the calculated value.Because i have already display the fields in view page using form editor.So now i will add my custom code on quotes view page to display the {c_newTotal} value?



#4 X2Raymond

X2Raymond

    Advanced Member

  • Administrators
  • 972 posts
  • LocationSanta Cruz, CA

Posted 24 May 2017 - 10:13 AM

That's correct, if you want the total value displayed elsewhere in the view besides the form layout, you'll want to add custom code to the view. You will be able to reference your field through the model, usually as $model->c_newTotal.



#5 vijayviswa

vijayviswa

    Member

  • Members
  • PipPip
  • 13 posts

Posted 24 May 2017 - 10:06 PM

Hi Raymond,

 

Actually  thank you so much for your great support  ... :)

 

I have try to put my custom code on view page like this way ($model->c_newtotal) but i can't able to get the value.Because i have checked the database c_newtotal filed but my work flow calculated value does not updated in that field.Here my screen shots for your reference.Please suggest me some idea and what's the problem on that page.

Attached Files



#6 X2Raymond

X2Raymond

    Advanced Member

  • Administrators
  • 972 posts
  • LocationSanta Cruz, CA

Posted 25 May 2017 - 09:26 AM

It appears each of the conditions in your workflow are evaluating to "No," which would explain why the field is not being updated. I'd recommend checking the condition on each of these to verify that they are testing for an expected value, and verifying that the operation is set before the trigger is fired. Based on the db screenshot you have included, it looks like the operation may have been unset when the workflow executed. Update the conditions according to what you find, ensure the record has it's operation set, then retest and check the trigger log to see if one of the conditions properly evaluates to "yes" and performs the update.







Also tagged with one or more of these keywords: staff response

0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users