Hi all,
I've created a 'GenerateOTP' service in ODC, but I've noticed the OTP generation is inconsistent. Specifically, the OTP should always be 8 digits long, but during testing, I found that my logic may have some issues.
To troubleshoot, I converted the test screen to O11, and the same behaviour persists. Just to note, in ODC we are using the CryptoRandomInt function instead of GetRandomInt in O11.
Could someone help me pinpoint if there's a logic error on my end, or is this expected behaviour within the OutSystems platform? This service is essential for our application, so I’d appreciate any insights.
Thanks!
Hello André Smit
Please try this OML and open it in your personal O11 service studio . I just changed the if condition you can check here
Thanks
Regards Gourav Shrivastava
Hello,
Since you are using a forge component and having issues with that, I would suggest you to initiate the discussion on component page to report your issue. Hopefully the concerned team will be able to assist you better.
Thanks,
Junaid
In this logic :-
I have found two suggestions:-
1) Why are you generation integers one by one instead of once by adding 0 to 99999999
2) And you are not reinitializing the counter variable if the code is not successfully generated.
Hi @Junaid Syed, thank you for your comment. I think there might have been a misunderstanding—I’m not using a Forge component. We’re currently developing in ODC, and I converted the screen to O11 because many users don’t yet have access to ODC.
@Gourav Shrivastava, thank you for highlighting the issues in my logic. However, I think that with your point number #1, it should stay as is. I am quickly doing further testing on my end.
EDIT: Never mind, I see it is still breaking... If I can numMax to 99999999 it just generates the '0000 0000' and the output just returns '0'.
You might need to share the updated OML then, since the original one does have the reference to the extension from forge.
My apologies @Junaid Syed - I see what you mean. I was under the impression it is a system action.
This makes it a bit trickier since in ODC there is a native server action. I might be mistaken but don't think it is the Forge component giving problems but rather my way of implementing the solution.
Hope this makes sense.
In ODC
I have made some changes to your code please check
Thanks for your effort, @Gourav Shrivastava.
I tried opening your OML.
Hi André Smit ,
If you’re looking to generate an OTP, I suggest trying the Generate Password (length, includeSpecialCharacters) function, which I've used before with good results. Although it’s typically for passwords, it works well for OTPs by creating random, secure codes.
Rounak Rawat