Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Field Dependency Business Mapping - set value from field
#1
I'm trying to setup a business map that would copy the value from quantity in description when a user pushes edit on a Contact.
I can assign constants with the <change> action but I can't assign values from a field on a same form. I tried this:
<map>
<originmodule> <originname>Contacts</originname> </originmodule>
<dependencies>
<dependency>
<field>firstname</field>
<actions>
<function>
<field>description</field>
<name>fieldDep_GetField</name>
<parameter>firstname</parameter>
</parameters>
</function>
</actions>
</dependency>
</dependencies>
</map>

... and play a bit around but I can't seem to get any value from the firstname field into description(or anywhere else). I tried to follow the wiki example for this but I could not get any result. I think I'm not doing it correctly but cannot find any other example to follow. So if anybody already done that please enlighten me Wink

Thanks.
Reply
#2
I understand that you want to copy the value of one field into another field when some other field changes. In other words

field A is the field that changes, the field triggering the dependency, when field A changes, you want to copy the value of field B to field C

did I get that correctly?
Joe
TSolucio
Reply
#3
fieldDep_GetField is to get information from a related module, not to get values from the current form on screen. for example if you are in a contact and want to read some information from the related account

from what I see in the map there is no way to copy field values from one field to another if it isn't the field triggering the change. so I added a new function to do that: fieldDep_CopyFieldValue

I added documentation to the wiki with a small example

let me know how it goes
Joe
TSolucio
Reply
#4
(01-12-2021, 11:47 AM)joebordes Wrote: fieldDep_GetField is to get information from a related module, not to get values from the current form on screen. for example if you are in a contact and want to read some information from the related account

from what I see in the map there is no way to copy field values from one field to another if it isn't the field triggering the change. so I added a new function to do that: fieldDep_CopyFieldValue

I added documentation to the wiki with a small example

let me know how it goes


I made some mistakes in the description of my example. Thanks for describing fieldDep_CopyFieldValue. What I would like to achieve in the Contacts example is whenever you push Edit, this business map will kick in and fill some fields for you(in my example, i don't care about any conditions I just want the fields populated). so if I have this definition:



Code:
<field>firstname</field>
<actions>
<change>
       <field>title</field>
       <value>example</value>
</change>
</actions>


then everytime i push edit(since i have no condition) the field title gets filled with the word 'example'. But if instead of a constant string i would like to fill the field title with the value that is in the field firstname then i would have to do:


Code:
        <function>

            <field>title</field>
            <name>fieldDep_CopyFieldValue</name>
            <parameters>
              <parameter>firstname</parameter>
            </parameters>
        </function>

And I would expect that everytime i push edit to get the firstname value filled in the title field. The first example works but the second example does not fill in the field. I have tried in the online demo and it doesn't seem to work. I have set in the same business map(in the online demo) the field title to constant 'title' and the assistant should be field with firstname value. Only the field title gets filled.

Thanks for helping, much appreciated Wink
Reply
#5
I haven't updated the online demo, so it won't work there
Joe
TSolucio
Reply
#6
ah, i see. I thought it was already in there just was not documented. I did update the code, still no effect. I hope this time i got the correct syntax. I could pass the value to a field in some other directly related module if you say that the other function can access fields in another module. And i don't mind if the user have to modify a field in edit in order to get the value(i could put a checkbox to trigger the fill if required, though it would be nice if it would behave like the <change> action). I will report back my findings.

Thanks alot!
Reply
#7
I was trying that right now. We need a field to change, in order for the actions to take place. I was trying to see if some picklist or the autonumber field were set and triggered the event but all the values are preset in PHP.
If you work with a checkbox or some other field that triggered the event it should work.
Joe
TSolucio
Reply
#8
I got it working with the trigger field!
So it works
Thanks alot Wink
Reply
#9
I spoke too fast again. I have a peculiar situation. The function fieldDep_CopyFieldValue in the business map works for my user but it does not work for others. The business map does kick in and fills other fields but it won't do any function with field operations. Any thoughts?
Reply
#10
show me the map. are the fields that it has to copy present for that user?
Joe
TSolucio
Reply


Forum Jump:


Users browsing this thread: 4 Guest(s)