• Global community
• Language:
• Deutsch
• English
• Español
• Français
• Português
• 日本語コミュニティ
Dedicated community for Japanese speakers
• 한국 커뮤니티
Dedicated community for Korean speakers
Exit
• Re: I need to replicate excel formula (D31)/SIN(RA...

# I need to replicate excel formula (D31)/SIN(RADIANS(D29)), using Simplified Field Notation

Community Beginner ,
Aug 28, 2018 Aug 28, 2018

Copied

Is it possible for me to replicate excel formula (D31)/SIN(RADIANS(D29)) using Simplified Field Notation?  I have been playing around with Math.sin(x) but cannot seem to get it to work.  Let's just say that D31 is field "Intended Load in lbs." and D29 is field "Angle in degrees".  Should it be intendedloadinlbs/Math.sin(angleindegrees)?

Any help would be greatly appreciated.

TOPICS
Acrobat SDK and JavaScript , Windows

Views

770

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more

Community Expert , Aug 29, 2018 Aug 29, 2018

I'm going to help you out a bit with this... Try this code:

`var v1 = Number(this.getField("slingsintendedload").valueAsString);var v2 = Number(this.getField("Slingangleindegrees").valueAsString);var v3 = Math.sin(degToRad(v2));if (v3==0) event.value = "";else event.value = v1 / v3;function degToRad(v) {    return v * (Math.PI/180);}`

15 Replies 15
LEGEND ,
Aug 28, 2018 Aug 28, 2018

Copied

Math.sin takes radians too, so you have to convert those degrees to radians. There's no function to do this, so just multiply by 0.0174533

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Community Beginner ,
Aug 28, 2018 Aug 28, 2018

Copied

Thank you Test Screen Name!  Just to make sure I am understanding correctly, would the text in Simplified Field Notation be (intendedloadinlbs/Math.sin(0.0174533(angleindegrees))

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Community Expert ,
Aug 28, 2018 Aug 28, 2018

Copied

You can't use the Simplified Field Notation to do it. It requires writing a custom calculation script.

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Community Beginner ,
Aug 28, 2018 Aug 28, 2018

Copied

Thank you try67.  I will have to research further and learn how to write a custom calculation script.  I have been tasked with creating a Critical Lift (Cranes and Rigging) PDF, which autofills certain fields based on the preset calculations, and I only have this last one left.  It's definitely a show stopper!

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Community Expert ,
Aug 28, 2018 Aug 28, 2018

Copied

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Community Beginner ,
Aug 28, 2018 Aug 28, 2018

Copied

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
LEGEND ,
Aug 28, 2018 Aug 28, 2018

Copied

It wouldn't be   0.0174533(angleindegrees)  it would be  0.0174533*angleindegrees  to multiply.

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Community Beginner ,
Aug 28, 2018 Aug 28, 2018

Copied

I greatly appreciate it!  Between your advice and the self help link provided by try67, I have a better shot of getting this figured out than before I posted my question on the forum.

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Community Beginner ,
Aug 28, 2018 Aug 28, 2018

Copied

Does this look more like it?  intendedloadinlbs/Math.sin0.0174533*angleindegrees

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Community Expert ,
Aug 28, 2018 Aug 28, 2018

Copied

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
LEGEND ,
Aug 28, 2018 Aug 28, 2018

Copied

As try67 mentioned earlier, you cannot use the simplified field notation option for this, you need to use JavaScript. The tutorial linked to earlier has more information in the "Custom calculation script" section at the end. The best thing you can do now is read those first three paragraphs.

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Community Beginner ,
Aug 29, 2018 Aug 29, 2018

Copied

Thank you for the help.  I am certainly no expert, which is why I am hoping someone can throw me a lifeline on this forum.  I have taken all suggestions and came back with this custom validation script.  I pray I am close to where I need to be.  Any suggestions would be greatly appreciated.

event.value = ( this.getField("slingsintendedload").value / Math.sin * 0.0174533 * this.getField("Slingangleindegrees").value

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Community Expert ,
Aug 29, 2018 Aug 29, 2018

Copied

First of all, move the code to be the field's custom calculation script.

Then, when you apply it, you should get this error message:

SyntaxError: missing ) in parenthetical

Fix that and then move on to the next problem, namely that you're not using Math.sin correctly, as it's a function and you need to provide it with a parameter within parentheses, for example:

Math.sin(90)

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Community Expert ,
Aug 29, 2018 Aug 29, 2018

Copied

I'm going to help you out a bit with this... Try this code:

`var v1 = Number(this.getField("slingsintendedload").valueAsString);var v2 = Number(this.getField("Slingangleindegrees").valueAsString);var v3 = Math.sin(degToRad(v2));if (v3==0) event.value = "";else event.value = v1 / v3;function degToRad(v) {    return v * (Math.PI/180);}`

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Community Beginner ,
Aug 29, 2018 Aug 29, 2018

Copied

LATEST

I cannot thank you enough try67.  I will eventually become more fluent with the coding, but again, this is my first time ever having a need to create such a code.  I am grateful for the experts on this forum, such as yourself, who is willing to take time out of their day and help the amateurs like me.