How to get the one Entity properties into another Entity?

0
Hi All,    I'm new to mendix, could you please help on this     Issue:  I'm working on Twilio two-factor authentication facing the issue in Verify OTP Rest API,  we have two entities (Mobile & OTP).     OTP Rest API:        Once enter the mobile number getting the OTP and call the Rest API.  (inputs - mobile number, country code, api_key) - its working fine  Verify OTP Rest API:       Here I have to pass the otp code, mobile number, and country code, How to get the mobile number and country code here?   How to associations for the Mobile & OTP Entities.             
asked
5 answers
1

Hi Shiva,

Based on your pictures, you're passing a string into the microflow. Try passing the object Otp. Then you can use a retrieve over association to get the Mobile object.

 



If you can only pass the code, you can retrieve the Mobile from database in a retrieve from database and using the following path [<MODULE>.Otp_Mobile/<MODULE>.Otp/Otp = $OTPString]

answered
1

Hello Shiva,

  You are very close, but there is one final step.  You have made the association correctly in the domain model, but you need to specifically set that the MobileNumber that you are interested is related to the OTP that you are dealing with in the microflow.  What is happening is you are trying to retrieve over association for a MobileNumber, but you have not yet set the specific mobile number that contains the right value to the OTP object in question.  Try this:

1) Identify where the Mobile object that contains the correct value for 'Mobile'  I suspect this is in another microflow that contains a GET rest action where the return object is a 'Mobile.'

2) In that microflow, where you have the Mobile object with the correct value, create a new OTP and set the association between this OTP and your mobile number.  This can be done using the 'Create' Microflow action.  Pick the association Mobile_OTP on your Mobile object and set the value equal to your new OTP object, which will be called $NewOTP

3) Pass this specific OTP object into the microflow you show in your screenshot.  The one where you create the log action.  Then you should be able to retrieve the Mobile object with the Mobile attribute set to your value. This should solve your problem.

If you are talking about sending a more complex, multi-level JSON package in your REST call, that can be accomplished but is a bit more complex.  Try steps 1-3 first and see if that solves your issue.

Best,

Rob

answered
0

If I'm understanding you correctly, you just want to know how to relate 2 entities?

If so you want to drag the association from the "Child" entity to the "Parent" entity to create a Many-to-One relationship. Meaning that 1 Mobile phone has many One-Time-Pins. You relationship will be called Otp_Mobile. 

You can then use this association in microflows to retrieve your mobile.

Obviously you will need to populate the association when you get the OTP. Not sure when/how that happens.

answered
0

 

 

 

 

 

 

Domain Model

 

OTP Microflow:

answered
0

answered