Reuse Calculated field

I have one calculated field. How can I use the result of this calculation at another place in same snippets? I don't know how to name this element.

I understand that, I can use the same formula at other places but is there any way I can name this field?

There are two main ways: with fields that share a name or with formula's.

Linked fields with the same name:

The company name is {formtext: name=company; default=Acme}. Again that is {formtext: name=company}.

One field, and then using a formula to reuse the value

The company name is {formtext: name=company; default=Acme}. Again that is {=company}.

1 Like

I guess I missed to explain my question.

I have few form text fields based on which I am creating formula field. Can we name this formula field to reuse it at another place?

You can assign it to a variable.

For example:

{x=1+1}

{=x}
{=x*2}
{=x}

1 Like

Got it. Thanks

1 Like

Hi Scott,

Need help in this context. Here is my snippet.

{note}
{formmenu: name=entity; default=Company; LLP}

Date of meeting: {formdate: dddd, MMMM D, YYYY; name=dateandtimeofmeeting; formatter=text->upper(text)} at {formtext: name=hours; default=10; cols=2}:{formtext: name=mins; default=00; cols=2}{formmenu: name=AMPM; default=AM; PM; cols=6}
{timeset=hours&":"&mins&AMPM} {=catch({time: h:mmA; at={=timeset}; pattern=h[:]ma}, "Invalid time")}
Registered Office: {formtext: name=ro; formatter=text->upper(text)}
{endnote}

CERTIFIED TRUE COPY OF THE RESOLUTION PASSED AT THE MEETING OF THE BOARD OF DIRECTORS OF _____ PRIVATE LIMITED HELD ON {=dateandtimeofmeeting} AT {=catch({time: h:mmA; at={=timeset}; pattern=h[:]ma}, "Invalid time")} AT {=ro}

I have done formatting for Date and Registered office (i.e. ro). While reusing same variable, the format is not being applied at other places. Can you please help?

EDITED by @Cedric_Debono_Blaze to turn into dynamic snippet

Looks like this is a simpler snippet for the same issue you're facing:

Date of meeting: {formdate: dddd, MMMM D, YYYY; name=dateandtimeofmeeting; formatter=text->upper(text)}
Registered Office: {formtext: name=ro; formatter=text->upper(text)}

{=dateandtimeofmeeting}
{=ro}

(You can enclose your snippet in [snippet]snip[/snippet] for nicer formatting :slight_smile: )

It seems to me that the formatter is more of a postprocessor that acts on how to display the variable value. The variable value is still lowercase, the formatter just makes it displayed in uppercase.

If you want to make the variable itself uppercase you'll have to do that separately, like so: {up_ro=upper(ro)} or something of that nature.

Hope that helps!

1 Like

Hi @Pratik_Shah,

Besides what @Gaurang_Tandon mentioned, you could do something like this:

{note: preview=no}
{timeset=hours&mins&AMPM}
{meetingtime=catch({time: h:mmA; at={=timeset}; pattern=hma}, "")}

{endnote: trim=right}
{note}
{formmenu: name=entity; default=Company; LLP}

Meeting date: {formdate: dddd, MMMM D, YYYY; name=meetingdate}
Meeting time: {formtext: name=hours; default=10; cols=2}:{formtext: name=mins; default=00; cols=2}{formmenu: name=AMPM; default=AM; PM; cols=6} {if: meetingtime==""}{error: Invalid time; block=yes}{endif}

Registered Office: {formtext: name=ro}

==============

{endnote: trim=right}

CERTIFIED TRUE COPY OF THE RESOLUTION PASSED AT THE MEETING OF THE BOARD OF DIRECTORS OF _____ PRIVATE LIMITED HELD ON {=upper(meetingdate)} AT {=upper(meetingtime)} AT {=upper(ro)}.

Would this be a suitable solution for you?

I've cleaned up the snippet and reworked a few things to make it more "fancy" :slight_smile:

Thank you for this. I was wondering how you people do that.

Thank you for all your help.

Thank you @Cedric_Debono_Blaze as always. This is what I was looking for.

We are almighty Text Blaze wizards with unlimited power and awesomeness, that's how... :rofl:

2 Likes

Here's my final version of snippet. Thank you both of you.

{note: preview=no}
{timeset=hours&mins&AMPM}
{meetingtime=catch({time: h:mmA; at={=timeset}; pattern=hma}, "")}

{endnote: trim=right}
{note}
{formmenu: name=entity; default=Company; LLP}
Name of {if: entity == "Company"}Company{else}LLP{endif}: {formtext: name=nameofentity}
Date of meeting: {formdate: dddd, MMMM D, YYYY; name=dateofmeeting}
Meeting time: {formtext: name=hours; default=10; cols=2}:{formtext: name=mins; default=00; cols=2}{formmenu: name=AMPM; default=AM; PM; cols=6}{if: meetingtime==""}{error: Invalid time; block=yes}{endif}
Registered Office: {formtext: name=ro; formatter=text->upper(text)}

Other Details:
Name of Owner: {formtext: name=nameofowner}
Premises Address: {formparagraph: name=newro}

Name of {if: entity == "Company"}Director{else}Designated Partner{endif} who is authorised: {formtext: name=nameofauthorised}
Name of {if: entity == "Company"}Director{else}Designated Partner{endif} who is signing the resolution: {formtext: name=nameofsign}
Name of {if: entity == "Company"}Director{else}Designated Partner{endif} who is signing the resolution: {formtext: name=dinofsign}
{endnote}

CERTIFIED TRUE COPY OF THE RESOLUTION PASSED AT THE MEETING OF {if: entity == "Company"}THE BOARD OF DIRECTORS{else}PARTNERS{endif} OF {=upper(nameofentity)} HELD ON {=upper(dateofmeeting)} AT {=upper(meetingtime)} AT {=upper(ro)}

“RESOLVED THAT the consent of the {if: entity == "Company"}Board{else}Partners{endif} be and is hereby accorded to execute a Leave and License Agreement between the {if: entity == "Company"}Company{else}LLP{endif} at one part and {=nameofowner} at other part; for the premises situated at {=newro} for use as Office of Company.”

"RESOLVED FURTHER THAT the draft of the proposed Leave & License Agreement to be entered into between the {if: entity == "Company"}Company{else}LLP{endif} at one part and {=nameofowner} at other part; be and is hereby approved".

"RESOLVED FURTHER THAT {=nameofauthorised} the {if: entity == "Company"}Director{else}Designated Partner{endif} of the {if: entity == "Company"}Company{else}LLP{endif} be and is hereby authorized to negotiate, finalize and execute the above mentioned agreement and other related documents on behalf of the {if: entity == "Company"}Company{else}LLP{endif} and to do all such acts, matters, deeds and things for doing registration of the Leave & License Agreement with Sub-registrar of Assurance in India and to take all steps and do all things and give such directions as may be required, necessary, expedient or desirable for giving effect to the said Leave & License Agreement."

Certified True Copy,
For {=nameofentity}


{=nameofsign}
DIN: {=dinofsign}
{if: entity == "Company"}Director{else}Designated Partner{endif}

Date: {=dateofmeeting}

@Cedric_Debono_Blaze I saw that you shifted following two lines to the top of snippets. I am curious to know the reason, if that affects anything?

{note: preview=no}
{timeset=hours&mins&AMPM}
{meetingtime=catch({time: h:mmA; at={=timeset}; pattern=hma}, "")}

{endnote: trim=right}

And would be interested to know more about =catch function. What exactly it does to time pattern.

Great job @Pratik_Shah!

It's just for aesthetic reasons. Those lines do not show anything in the preview, so I placed them into a {note} block with the preview setting set to "no", so they don't show up as empty lines.

catch allows you to specify what happens when a command produces an error.

In my case, I used the catch with the results of the time command, so that if I get an error, it gives me "" (meaning "empty"). Further down, I used an {if} command together with the {error} command, to bring up an error message when the variable is empty. The block setting prevents you from inserting the snippet unless the error is resolved.

You can read more about these commands and functions here:

1 Like

Thank you for explaining.

1 Like

Anytime :slight_smile:

Hi @Cedric_Debono_Blaze

I have extracted some information using site command with help of @Gaurang_Tandon. How can I add name variable to that information and reuse the same for further purpose?

Thanks

Hi Pratik, can you give more information on your use case, sorry I do not understand your request.

1 Like

I am using following snippet to extract information from a website.

{site: text; selector=#content > div > div > div > div.details.pt-2 > ul > li:nth-child(1) > div.open > div:nth-child(7) > div.fleft.lblrgt}

This is extracting some information from website. Similarly I will extract many such information from same website (alongwith those information for which you have helped).

I want to send all these information to google sheet using this snippet of Scott.

Like for any calculated fields, we can name it like

{total=2*2} {=total}

I can then use {=total} to anywhere in snippet to insert output. Can I add such name variable to value retrieved from site command. For Example,


I want to give name variable as "address" so that I can reuse it for another purpose. but I guess I am doing it wrong.

Is this possible?

EDIT:
I guess after exploring community, I could add name variable to it.

{address=({site: text; selector=#content > div > div > div > div.details.pt-2 > ul > li:nth-child(1) > div.open > div:nth-child(7) > div.fleft.lblrgt})}

1 Like

Hi @Pratik_Shah,

Small correction, you don't need the round brackets after the first equals sign and the final curly bracket.

{address={site: text; selector=#content > div > div > div > div.details.pt-2 > ul > li:nth-child(1) > div.open > div:nth-child(7) > div.fleft.lblrgt}}

1 Like

Thank you @Cedric_Debono_Blaze

1 Like