Solved

@SetField problem

Posted on 2001-08-28
8
393 Views
Last Modified: 2013-12-18
I have a field (FIELD1) defined as Text,Editable.

Another field (FIELD2) defined as Text,Computed,Allow Multiple Values,Hidden.

And Another field (LOCATION) defined as Numeric,Hidden


What I want to do is update FIELD2 based on the value in FIELD1 slotted with the value of LOCATION.

So, If Field1 = AAAA and Location = 1, then FIELD2 should be AAAA, Field1 is blanked and Location set to 2, if the user puts BBBB into Field1 then Field2 should be AAAA;BBBB.

I have the formula to update the field in a hotspot but the field will not update into the correct slot, it keeps getting added to the end of Field1.

The formula I am using in the hotspot is:

@SetField(@Subset("Field2";Location);Field2 + Field1 + ";");
FIELD Field1 := "";
FIELD Location := Location + 1;

@Command([FileSave])

Anyone have any ideas?

0
Comment
Question by:GaryZ
8 Comments
 
LVL 4

Expert Comment

by:martijnmulder
Comment Utility
try:

FIELD Field2:= Field2:Field1;
FIELD Field1 := "";
FIELD Location := Location + 1;

@Command([FileSave])

 
0
 
LVL 1

Expert Comment

by:tduthie
Comment Utility
I don't quite see the use of the Location field.  Since it is hidden, I don't see why it's necessary.

FIELD Field2:= Field2:Field1;
FIELD Field1 := "";
@Command([FileSave])

I'd completely get rid of the Location field, unless you can tell me why it's necessary.
0
 

Author Comment

by:GaryZ
Comment Utility
The reason for the location field is to know what slot the information is slotted.

There are 3 locations, thus 3 values in the multi-value field (location 1, location 2, location 3).

When I display the field I need to know what location I am displaying and thus the appropriate value.

My problem is everytime someone clicks on the "Add Location" link it keeps adding the information to the multi-value field. Also to carry this forward, they might want to update location 2, so I need to replace that value with the new one.
0
 
LVL 1

Expert Comment

by:tduthie
Comment Utility
From your comments above, I'm getting the impression, that you may be changing Location in other code.  As a result, to replace a specific member in the list requires a bit more code.

In the code below, I didn't do an @Command([FileSave]).  That's up to you if you want to do.  Also, my Location field was defaulted to "1".  You may want to check that Location is not "".

--Begin Formula--

REM "Get count in list before current location";
varSubsetBefore := Location - 1;
REM "If there are elements after current location, get count in list after current location";
varSubsetAfter := @If(@Elements(Field2) > Location; -1 * (@Elements(Field2) - Location); 0);

REM "Set Value of Field2";
FIELD Field2 :=
    @If(varSubsetBefore != 0 & varSubsetAfter != 0;
        @Subset(Field2; varSubsetBefore) : Field1 : @Subset(Field2; varSubsetAfter);

        varSubsetBefore = 0  & varSubsetAfter != 0;
        Field1 : @Subset(Field2; varSubsetAfter);

        varSubsetBefore != 0 & varSubsetAfter = 0;
        @Subset(Field2; varSubsetBefore) : Field1;

        Field1
    );

REM "Clear Field1 and increment Location";
FIELD Field1 := "";
FIELD Location := Location + 1;

@True;

--End Formula--

0
Better Security Awareness With Threat Intelligence

See how one of the leading financial services organizations uses Recorded Future as part of a holistic threat intelligence program to promote security awareness and proactively and efficiently identify threats.

 

Author Comment

by:GaryZ
Comment Utility
I get the same resuts with your code as mine, the multi-value field is not updated.
0
 
LVL 1

Accepted Solution

by:
tduthie earned 300 total points
Comment Utility
What's the formula for your multi-value field?  Mine's simply "Field2".  If it's anything else, that value will always replace whatever is in the field.
0
 

Author Comment

by:GaryZ
Comment Utility
Send me your email address at gmorrison@celinagroup.com and I will send you a small database I am using to test.
0
 
LVL 4

Expert Comment

by:sloeber
Comment Utility
Did you try Martijns solution ?
It should work ?
0

Featured Post

Find Ransomware Secrets With All-Source Analysis

Ransomware has become a major concern for organizations; its prevalence has grown due to past successes achieved by threat actors. While each ransomware variant is different, we’ve seen some common tactics and trends used among the authors of the malware.

Join & Write a Comment

You’ve got a lotus Domino web server, and you have been told that “leverage browser caching” is a must do. This means that we have to tell the browser everywhere in the web to use cache. In other words, we set (and send) an expiration date in the HT…
Article by: Rob
Notes 8.5 Archiving Steps and Tips This article covers setting up a Notes archive, and helps understand some of the menu choices making setting up and maintaining a Notes archive file easier.
This video discusses moving either the default database or any database to a new volume.
You have products, that come in variants and want to set different prices for them? Watch this micro tutorial that describes how to configure prices for Magento super attributes. Assigning simple products to configurable: We assigned simple products…

772 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

12 Experts available now in Live!

Get 1:1 Help Now