Hi! I was creating a PO interface and I want two of the fields to appear automatically:
1) Field 1: NomProv (supplier name)
- In this case, I have a record type in which a "NomProv" value (and also, the NIF number, an extra field) is assigned to each username ("usuario"). It is an static record, and I want it to make relations between the fields, and obtain the "NomProv" for each username ("usuario")
To obtain the nomProv for each user logged in, I created the following rule expression:
In this case, I´m logged in as carlos.paz.pelaez@pwc.com, so it returns the value "Proveedor 2" as a test output (works fine for me)
But the fact is that I want to pass this test output ("Proveedor 2") to a field in my interface so that the user cannot change it. But I dont know how to pass the rule expression output to the text field! Also, I tried to pass the value as a local variable, but it is not allowed:
2) Field 2: NIF
- After passing the suppliers name ("Proveedor 2"), I want the NIF text component to be generated automatically using the relation between nomProv and NIF (each nomProv has one NIF associated in the record . type). To make it easier to understand, my idea was to do another query (I pass the nomProv value, which is saved in a rule input of the interface---> returns the NIF as an output --> i save it into the interface) , but I would like to listen to your recommendations. How can I do it?
Any help would be useful. Thanks for your time!
Discussion posts and replies are publicly visible
Just call this expression rule you have created, in an interface and save it in a local variable and use it in the Proveedor text field "value" parameter by indexing the field.
For NIF you can either create a new queryRecord Expression or use the created one and add the relationship using relatedRecordData()
You can take reference from below:
local!Proveedor: property(rule!CPF_ObtenorNomProveedor(),"data",null), /*Create another query record rule for NIF and pass the proveeder value as below*/ local!NIF: property(rule!NIFQuery(Proveedor: property(local!proveedor, recordType!CPFMaestroProvedores.nomProv, null)),"data",null), /*in the value parameter of Proveedr field*/ value: property(local!proveedor, recordType!fieldName, null), /*Value parameter of NIF field*/ value: property(local!NIF, recordType!fieldName,null)
Thanks! I understand the idea and makes sense to me! I´m trying but it seems like the call to the expression rule is returning a rule value:
I put it in the display value but, logically, the field is in blanck (null value):
*The local variable usuario was just for check that the function loggedinUser is returning me the correct username
Can you please make sure that the rule itself is returning any data for this user and paste the rule expression here?
Sure, the rule is returning the correct data:
If you have indexed "data" already in the expression rule then there is no need to do it in the interface when you are calling the rule, simply use :
local!data: rule!ruleName()
I tried this and now I can return the data value, but it is not what is expected. Instead of returning only the value "Proveedor 2" it is returning this:
What expression you have used in the display value?
I´m using the following expression: local!data
But the fact is that the value stored in the local variable is not "Proveedor 2". I think the problem is in the rule expression output. I revised my expression rule and put it in raw format, finding that the value stored is not exactly "Proveedor 2":
And, in fact, the value displayed in the interface is the test output, but I don´t want this, I would like to have only the nomProv field "Proveedor 2". How can I do this?
yeah - that's why I asked what expression you have used in the display value of text field? since this is a result from queryRecordType, you need to index the record field from the result using property() function and recordType! domain, like I mentioned in my first reply i.e.,
property(local!data, recordType!fieldName, null)
I tried with the property function and it works correctly! Thanks a lot Sanchit