Changing values of check box

Hi All,

I have a check box “Subjects”. The values for these are defines as:

Artificial Intelligence | AI

Computer Graphics

Discrete Algorithms

We planned to change the subjects and map the above subjects to the new set of three subjects. The new set is:

Business Intelligence

Discrete Mathematics

Computer Arch

The mapping of old subjects with the new subjects is :

Artificial Intelligence → Business Intelligence

Computer Graphics → Computer Arch

Discrete Algorithms → Discrete Mathematics

I want to write an agent that will take all documents and change the subjects and retain the old values as per the new mapping? Can someone please help me

Thanks in advance.

Subject: Changing values of check box

I am slightly confused by what you are trying to achieve. You say:

“I want to write an agent that will take all documents and change the subjects and retain the old values as per the new mapping?”

First you say that you want to change the subjects, but then you say “and retain the old values as per the new mapping?” What does this mean? And where would you want to retain the old values?

Subject: RE: Changing values of check box

Hi Jade,

Thanks for such a quick response.

I am sorry if my explaination was confusing. Let me try to rephrase it.

We have the field Subjects on a form. The values are :

Business Intelligence

Discrete Mathematics

Computer Arch

Since it is a check box, multiple subjects can be selected. So, the documents created by this form can have some or all of the subjects selected.

Now we have to change the values of this Subject field to the new set that is :

Artificial Intelligence

Computer Graphics

Discrete Algorithms

The mapping of old subjects with the new subjects is :

Artificial Intelligence → Business Intelligence

Computer Graphics → Computer Arch

Discrete Algorithms → Discrete Mathematics

I think I should not have used the word Retain, as Mapping itself is self descriptive.

Can you please help me how can I provide the above mapping.

Thanks again.

Subject: RE: Changing values of check box

Okey dokey… I am working on the assumption that the following values need amending as follows:

CURRENT VALUE = Business Intelligence / NEW VALUE = Artificial Intelligence

CURRENT VALUE = Discrete Mathematics / NEW VALUE = Computer Graphics

CURRENT VALUE = Computer Arch / NEW VALUE = Discrete Algorithms

I am also assuming that the field name is SUBJECTS

I am also assumuing that you have already updated the values in the Field Properties > Choices section to be the new values.

As such, the following code should work in an agent:

FIELD Subjects:= @Replace( Subjects ; “Business Intelligence” ; “Artificial Intelligence” );

FIELD Subjects:= @Replace( Subjects ; “Discrete Mathematics” ; “Computer Graphics” );

FIELD Subjects:= @Replace( Subjects ; “Computer Arch” ; “Discrete Algorithms” );

SELECT @All

Points to note:

a) If the field type is a Checkbox, the code above will work. Checkboxes save data as text lists. If you use a different type of field, we might need to use @Explode in there, but try this first.

b) You ought to consider aliases in your checkboxes. For example, in the field properties you probably have something like this listed:

Artificial Intelligence

Computer Graphics

Discrete Algorithms

If you had aliases too, you would never need to change “old” value programatically. If you were to use:

Artificial Intelligence | 1

Computer Graphics | 2

Discrete Algorithms | 3

then the numeric values would be saved with docs. You could then edit form properties whenever you wanted, and change the values (“artificial intellegence” for example). The form would automatically display the “new” values. You might have to change a view column or two, but at least you’re not changing data on documents…)

Subject: RE: Changing values of check box

Am I still confusing??? :frowning:

Subject: RE: Changing values of check box

Create an agent with @Replace as below:

from:= “A” : “B” : “C”;

To := “X” : “Y” : “Z”;

FIELD Subjects := @Trim(@Replace(Subjects;

from; To));

If subjects field in a document contains A & C as values, this formula will update the values as X & Z

Subject: RE: Changing values of check box

No I understand. Sorry for delay, had my lunch break and now need to do something for my boss. I’ll try and post code before end of day UK time…