cancel
Showing results for 
Search instead for 
Did you mean: 

SAP MDK how to get build version

0 Kudos

Hello,

I'd like to show MDK build version running on device in About page, so users know which version they use. But, getVersionInfo doesn't seem to return app build version. Is there a way to read App build version running on device?

Thanks.

Jitendra_Kansal
Product and Topic Expert
Product and Topic Expert
0 Kudos
mdk.learner

Were you able to resolve your issue? If any of the below responses helped you, then please mark the helpful answer by accepting it OR post an answer so others might benefit from your findings and then close this discussion.

Regards,
Jitendra (SAP Community Moderator)

View Entire Topic
FranciscoSAP
Advisor
Advisor
0 Kudos

Hi mdk learner

If you are referring to your own app's build number you can get it by accessing the ActionResult object created by your ApplicationUpdate type action. Here's my Update action metadata for reference:

{
"ActionResult": {
"_Name": "AppUpdate"
},
"OnFailure": {
"Name": "/pmp_smart_pm/Actions/Messages/GenericBannerMessage.action",
"Properties": {
"Animated": true,
"Duration": 0,
"Message": "Hubo un error al intentar actualizar la aplicación: {#ActionResults:AppUpdate/error}"
}
},
"OnSuccess": "/pmp_smart_pm/Rules/Application/AppUpdateResult.js",
"_Type": "Action.Type.ApplicationUpdate"
}

You could then assign a rule to the OnSuccess event of your update action and from that rule access the ActionResult object created by said action this way:

let result = clientAPI.actionResults.AppUpdate.data;
let versionNum = result.split(': ')[1];

I recommend you debug this rule so you can check exactly which information this object contains.

Since you want to persist this information to be able to display it permanently in another page, you should then store this value in your Application Settings. Keep in mind that Application Settings data is persisted through application launches so you need to be careful about what you store in there, the recommended practice is to chain a rule onto your LogOut action with logic that ensures your App Settings data is cleared every time a user logs out of your app.

Hope you find this helpful!

0 Kudos

Hi Francisco,

It seems default App Update is working via OnWillUpdate event and OnDidUpdate event. Is there a way to read the version upon OnDidUpdate event?

Thanks.

FranciscoSAP
Advisor
Advisor
0 Kudos

mdk.learner

I personally don't know of a way to do it with the default update behavior as you need to know the name of the ActionResult object in order to access it. What I would do is edit the default OnWillUpdate rule to trigger your own Update Action instead and then continue with the logic I described earlier.

Another less dynamic way of achieving what you are after would be manually editing your app version value contained in your /Globals folder (filename AppDefinition_Version.global). If you are building your own clients with the MDK SDK CLI you might need to edit that value in your MDKProject.json file too.

You could then access the version you declared by using clientAPI's getVersionInfo() method. If you have both iOS and Android users keep in mind that the property containing your app version might have a different name depending on your OS.

This second way I described, although less dynamic, it would give you full control of the version you display while my original suggestion only returns the total count of deploys you performed to that particular endpoint.

0 Kudos

Thanks, Francisco.

I had thought about replacing OnWillUpdate with the ApplicationUpdate action, but then, I noticed that the default procedure(closeoffline action and initializeOffline action) and ApplicationUpdate action are different. So I wasn't sure if it is safe enough to replace with ApplicationUpdate. I will try this way.

Thanks for your help!

bill_froelich
Product and Topic Expert
Product and Topic Expert

Keep in mind that the bundle version is not really a build version number. It is simply a sequential number assigned to each uploaded version. If you reset app update the numbering restarts at 0 or if you upload the same file a second time it will become a new revision in App Update.

Also, this number probably isn't consistent between landscapes (DEV, QA, PROD) for the same metadata version.

I would recommend using the Version in Application.app instead which is available from getVersionInfo.

0 Kudos

Hi Bill,

Could you please explain a bit more about "using the Version in Application.app"? When I use getVersionInfo, Application Version is 6.1.0, I don't know where it is from. It seems just the same as Client version.

Thanks.

0 Kudos

Hi Bill,

I copied program from demo. Demo shows creating a variable under Global, and assigning it in Version in Application.app. But, app update is checking build number for new version. I'm not sure how I can maintain the app version differently from build number if app is checking build number as new version unless I change the Version every time I deploy( i am using BAS ). Also, how can I match it between dev,qas,prd as you mentioned?


Could you please give me some guide what the best practice is for version control for app update?

Thanks.