Sign in to follow this  
Followers 0
angbrav

Problem with InsertCalculatedResult

14 posts in this topic

Hi everyone!

I am trying to do something which I think it should be quite easy to implement. I have a layout (called Projects) from which I create new Budgets, which it is a different layout and table. Both tables are linked by a field in the DB.

Therefore, what I am trying to do is a script which goes from Projects to the other layout and create a new record. My problem is the following; I need to link both tables inserting the value of the field id of Projects table to the field projectID of Budgets table. I am getting an error because the field projectID is not in the Budgets layout.

What I am trying...

set Variable [$code;Projects::Code]

goTo Layout [budgets]

new Record/Request

Insert Calculated Result [budgets::projectID;$code] --> At this point, I am getting error number 102 (Field is missing)

I know I could solve it including the field in the layout, but I am sure there is an elegant way to do it!

I hope I have clearly express myself. Thank you in advance!

Share this post


Link to post
Share on other sites

This is (one) of the problems in using Insert Calculated Result ... it must be on the layout.

Use Set Field [ ] instead and see how it goes. :^) Set Field [ ] is always the preferred step.

This is (one) of the problems in using Insert Calculated Result ... it must be on the layout.

Use Set Field [ ] instead and see how it goes. :^) Set Field [ ] is always the preferred step.

1 person likes this

Share this post


Link to post
Share on other sites

ohh yeah!! It works!!! Thank youuuu

Share this post


Link to post
Share on other sites

insert calculated result is useful of you want to append some text to the end of text already in the record (not replace)

Share this post


Link to post
Share on other sites

I'm using the insert calculated result to populate a field (global) with many data and then copy it to the clipboard so I can paste it to a word prossesor.

I'd prefer not to have the global field shown but, is it compulsory too to have that field in the layout to use the copy command or is there a way to copy directly to the clipboard a calculation?

Thank you.

Share this post


Link to post
Share on other sites

As far as I know, Copy is required to place data onto a clipboard.

Share this post


Link to post
Share on other sites

is there a way to copy directly to the clipboard a calculation?

Not natively, though you could use a plugin or - in OS X - AppleScript for this. Anyway, the global does not have to be visible or even enterable.

Share this post


Link to post
Share on other sites

With visible you mean, not seen (transparent content and borders) but placed in the layout. If is not in the layout it doesn't make the calc for me.

For me it's ok, I don't need anything else.

I copy all the data where the insert calculated result has placed it and even I delete it after.

Thanks for your advices.

Share this post


Link to post
Share on other sites

With visible you mean, not seen

Yes.

1 person likes this

Share this post


Link to post
Share on other sites

Use Set Field [ ] instead and see how it goes. :^) Set Field [ ] is always the preferred step.

Can Insert Calculated Result do anything that Set Field can't or can we get by without it?

Share this post


Link to post
Share on other sites

Primary difference between Insert Calculated Result and Set Field is that the field that you are targeting must be on the current layout

The Insert Calculated Result is kind of a holdover from previous versions allowing easier upgrading.

HTH

Lee

Share this post


Link to post
Share on other sites

Primary difference between Insert Calculated Result and Set Field is that the field that you are targeting must be on the current layout

The Insert Calculated Result is kind of a holdover from previous versions allowing easier upgrading.

HTH

Lee

Thanks Lee. I actually used Set Field just this week which worked great after previously trying to use Insert Calculated Result. Just shrugged my shoulders and carried on. I now know why it didn't work. ;)

Share this post


Link to post
Share on other sites

There are some things which can only be accomplished with Insert Calculated Result[] or at least be accomplished easily. If you check FM Help, it 'replaces only the selected portion of the current field, or inserts the result at the insertion point.'

*Replacing only the 'selected' portion of a field can't be done any other way and neither can inserting text at the insertion point. There are a few other reasons which do not come to mind right now. But Set Field[] is the workhorse of scripting. The fields you set do not need to be on the layout and if the field is global, it does not even need to be in a related table - its value can be set (or retrieved) from anywhere.

* okay, there are workarounds without using Insert Calculated Result[] but they are convoluted. And why use workarounds when this script step handles them nicely, LOL?

Edited by LaRetta

Share this post


Link to post
Share on other sites

There are some things which can only be accomplished with Insert Calculated Result[] or at least be accomplished easily. If you check FM Help, it 'replaces only the selected portion of the current field, or inserts the result at the insertion point.'

*Replacing only the 'selected' portion of a field can't be done any other way and neither can inserting text at the insertion point. There are a few other reasons which do not come to mind right now. But Set Field[] is the workhorse of scripting. The fields you set do not need to be on the layout and if the field is global, it does not even need to be in a related table - its value can be set (or retrieved) from anywhere.

* okay, there are workarounds without using Insert Calculated Result[] but they are convoluted. And why use workarounds when this script step handles them nicely, LOL?

Aha, still a useful script step then. I'll have to check out how to specify which text you want to replace or how to specify an insertion point.

Thanks LaRetta :smile:

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!


Register a new account

Sign in

Already have an account? Sign in here.


Sign In Now
Sign in to follow this  
Followers 0

  • Similar Content

    • By shevyshevy
      Hi All,
      I don't really know if the Title really explains my situation, but here it is..
      I have Four Fields: Name, Gender, Class and Policy
      Policy Field is an Unstored Calculation with the calculation below with result set to Text
      If ( Gender = "Male" &  Class = "Primary"; "RUNNING" ;"EXPIRED")
      Meaning, my intention is to Set the Policy field as Running, if the Student is Male and in Primary Class, otherwise, it should be set to Expired..
      The calculation does not work, some fields are displayed correctly with the correct value while others are not.
      However, if I remove the Logic "&" from the calculation making it only a single criterion, If ( Gender = "Male" ; "RUNNING" ;"EXPIRED"), then it works well..
      Why can't I compare several fields using "&"  or "OR"  with that function?
      Is there a better way of actualizing this?
       
    • By adrianatwork
      I am importing a csv file and need to use matched field names when importing: the provider of the file adds fields from time to time. However one of the field names in the cvs file ends with a space and when managing field names I do not seem to be able to define a field name which ends in a space. Every time I do the field name has the trailing space removed when I save it. Does anyone have a solution?
      Thanks in advance.
    • By dkey
      Hi all
      After moving to FMP advanced 13 I still don't know how to automatically add a new field in the current layout I work on.
      Before it was simple but now I always need to drag the icon into the layout in Layout mode.
      Is there a way to tell the app to ALWAYS add new fileds to the current layout
      Thanks a lot
       
    • By Pyorkie
      Hi
      Anyone have an idea on how to display the Record number in a field?
      I want the field to display the record number every time I got to the "Next or Previous" (scroll through) record.
      Thanks in advance for any help.
       
      pyorkie
    • By Philip Curtis
      Hi all,
      I am new to the forum and new to FM-Pro14.  I have been knee-deep reading books and tutorial videos on it for 2-3 weeks so far.
      I am stuck on a problem and I can not find any documentation.  I wonder if someone can help.  I am guess this is an easily solution and my beginner status is the problem <;
      When I create a new button, or modify the existing button, it keeps reverting back to being part of a Group.  I have 'Arrange-->Ungroup' many times without success.  
      When I go back to Browse mode and click the button, all fields are selected.
      When I go to Layout mode and select the button alone, then select 'Arrange-->Ungroup' (it greys out-temporarily), the Right-Click and select 'Button Action'-'Single Step', I continually get a message saying the button is part of a group.
      When I select all fields while in Layout mode and then select 'Arrange-->Ungroup', it is greyed out which tells me they are not part of a group.  But back in Browse mode selecting the button selects all fields.
      I've been doings circles with this without resolution.  Whew!!
      Is it possible I did something incorrectly when I first started by dragging all the fields at once onto the Layout from the Field Picker?
      Thanks,
      Phil
      BTW, the problem is associated with this text:
      Attach a button definition to an existing object or objects, like text or a field Select the object(s) and choose Format menu > Button Setup. If you select multiple objects, select only objects that have no previous button definitions. FileMaker Pro groups the objects when you define them as a button. See Grouping and ungrouping objects. If you attached a button definition to an existing object, you can only use an action for the button, so skip to step 5.   https://www.filemaker.com/help/14/fmp/en/html/create_layout.9.47.html https://www.filemaker.com/help/14/fmp/en/html/edit_layout2.11.16.html#1192005   I have read and re-read these pages without resolution. The message I get is the button can only be used for an action.  But I have not 'attached a button defination to an existing object'  Where can I see the status of this? Am I on the right track here? Thanks again, Phil