cancel
Showing results for 
Search instead for 
Did you mean: 

How to disable/enable extension fields dynamically using logic

Former Member
0 Kudos

Hello all,

I have created some extension fields in CoD using KUT. I want to disable these fields based on some logic. How can I achieve this?

I have tried using SDK by creating reference to these fields but they are not seen in the UI desiner or extensibility explorer.

Any help is appreciated.

Accepted Solutions (1)

Accepted Solutions (1)

Former Member
0 Kudos

Hi Mahesh,

As vinod explain that you can use Key user 's fields in ABSL script but only for writing your logic.

Unfortunately You can not set the property of Extended field using SDK, to make any changes on std screen it will require extensibility explorer and you can add fields but can not change the property.

You want to hide ext-field using some logic,using reuby script we can set the visible property disable/enable based on some other information, again ruby scripting for Standard fields is not available.

Regards:

Sunil

Former Member
0 Kudos

thank you all for the replies.

The requirement is to not allow users to change values in these custom fields. But the system user can change because the values for these fields come from CRM.

I need to find a way to decide who is editing these fields and may be on-save function, I can throw an error message and not save the BO.

any ideas?

vinodkumar_kommineni
Active Contributor
0 Kudos

Hi Mahesh,

If this is the scenario you are looking at I think it is achievable using Fields & Actions Tab in Business Role  .

Here you can restrict the access to Fields and Actions Users can perform on the Extension fields added trough Adaption Mode. When you asked Dynamic I thought it is really dynamic in nature.

Follow the Below steps to achieve it

Open the Business Role from Application & User Management -> Business Roles -> Click View All Button.

Here E-Mail is a field added to Business Partner/Account General Info.

Hope this helps you to achieve your use case.

Regards

Vinod

Former Member
0 Kudos

Hi Vinod,

Sorry i did not clearly state the requirement.

Users will be able to create prospects in CoD and enter email address in the custom field. This prospect flows to CRM->ECC, gets confirmed by the internal sales team and converted to an account. This account flows back to CoD with the prospect flag as false. From this moment, no changes can be made to that account in CoD.

Unfortunately, I have already created this custom field (plus some more fields) using key user tool and downloaded the initial data entirely. I should have created these in the SDK so that I could control their functionality.

So, coming to the requirement, is there any way to identify the user who is changing the record (account)? if it is a business user and trying to edit any fields, in on-save, we can return false if the prospect indicator is false.

Or any other ideas are welcome and appreciated.

I have used the procedure mentioned by you(fields and actions in roles) for some fields, but for our case it is not sufficient.

thanks

Mahesh

vinodkumar_kommineni
Active Contributor
0 Kudos

Hi Mahesh,

what I can say is it could have been much easier if it was from Studio .

I am not sure how the integration happens here. If the data is sent trough a single service user having access to cloud?, probably then you can do it the way you mentioned. If that is not the case it would be good if you can at least make out the system which is making changes.

You can get the current users identity UUID using

Context.GetCurrentIdentityUUID(); and build your logic.

But this is not as good as disabling the fields on UI because it will confuse user when He/She clicks on the fields as they turn in to edit mode and you throw an error message when He/She tries to save the changes saying you are not authorized.

Anyways I think you have visited all the options and nothing is left, Meanwhile check with SAP if possible, is there any alternative way to disable fields for your use case.

Regards

Vinod

Former Member
0 Kudos

Thanks Vinod.

actually, i am planning to wait for a few days as we are going live on 18th. If the issue seems to be big, then I will proceed with these changes.

also, the function Context.GetCurrentIdentityUUID() which you mentioned gives the UUID. Is there any other one which gives the user id? Because finding UUID of the system would be very hard and to be hardcoded. (which is a very bad idea).

vinodkumar_kommineni
Active Contributor
0 Kudos

Hi Mahesh,

There is no direct function to find a User ID of the current user. The reason might be because it is not constant over the time. ID can change but UUID will remain constant.

Anyways once you have the UUID its a matter of Executing a Query.

Below code snippet should fetch you the current Logged In User's ID.

import ABSL;

import AP.PC.IdentityManagement.Global;

    var UserUUID;

    var UserID;

    var QI ; // Query Identity

    var SP ; // Search Parameter

    var QR; // Query Result

   

    UserUUID = Context.GetCurrentIdentityUUID();

    QI = Identity.QueryByElements ;

    SP = QI.CreateSelectionParams();

    SP.Add(QI.UUID.content, "I", "EQ", UserUUID.content);

    QR = QI.ExecuteDataOnly( SP );

    if( QR.Count( ) > 0 ){

       

    UserID = QR.GetFirst().ID.content;

    }

Again remember User ID can be changed.

Regards

Vinod

Answers (2)

Answers (2)

HenrikeGrötecke
Product and Topic Expert
Product and Topic Expert
0 Kudos

Hi Mahesh,

Please refer to the following topic in the documentation of the studio, available as of version 1305:

"Create a Role-Based Flexible UI Using a UI Switch".

I hope this helps.

Kind regards,

Henrike

vinodkumar_kommineni
Active Contributor
0 Kudos

Hi Henrike,

We had used UI Switch in our project and It is only possible to use the fields that are available with in the UI Designer. So I do not think this option will work out for this use case. Unfortunately we have to live with this limitation.

Regards

Vinod

Former Member
0 Kudos

Hi,

I know this thread is from last year but just want to know is it still not possible to change the UI property of KUT field (make them read-only etc.) using some logic in SDK ?

I have created a separate thread for my question http://scn.sap.com/thread/3674654

Thanks,

Shobhit

vinodkumar_kommineni
Active Contributor
0 Kudos

Hi Mahesh,

Only using the Extension fields in ABSL is supported as per my knowledge, from 1308 by using the reference(.ref) to them within your solution. But I do not think there is a possibility to modify the UI properties like Read Only or Visible etc as of 1311 as well.

In your case you might need to add the fields using Cloud Studio itself if you want to dynamically control them.

Regards

Vinod