Saviynt unveils its cutting-edge Intelligence Suite products to revolutionize Identity Security!
Click HERE to see how Saviynt Intelligence is transforming the industry.
Saviynt Copilot Icon

customproperty is saved with trailing comma

Ibiza
New Contributor II
New Contributor II

Hi,

I have customized the AD group creation screen to add a select on things coming from db.

Here is the code : 

<div class="col-md-6">
<div class="form-group">
<label class="control-label col-sm-4">
Target Application<span style="color:red">*</span>
<a href="javascript&colon;;" class="help tooltips" data-placement="bottom" data-toggle="tooltip" title="Target Application">
<i class="icon-info-sign"></i>
</a>
</label>
<div class="col-sm-8">
<select class="form-control select2_category mandatoryselect2" data-placeholder="Target Application" tabindex="1" id="applicationLinked" name="customproperty51">
<option value=""><g:message code="Select.default.label" editable="true"/></option>
<g:each var="row" in="${targetApplications}">
<option value="${row.Attribute1}" ${params.customproperty51?.equals(row.Attribute1) ? 'selected' : ''}>${row.Attribute2}</option>
</g:each>
</select>
</div>
</div>
</div>

Displaying looks good and values of the selct button look good.

The problem is that when I check the group created, customproperty51 is having a comma at the end, like  : 520,

This is despite the fact that my select is not a multiple choice select one.

Anyone to help here, please?

 

Thanks.

 

 

 

10 REPLIES 10

rushikeshvartak
All-Star
All-Star

Add java script

<div class="col-md-6">
<div class="form-group">
<label class="control-label col-sm-4">
Target Application<span style="color:red">*</span>
<a href="javascript&colon;;" class="help tooltips" data-placement="bottom" data-toggle="tooltip" title="Target Application">
<i class="icon-info-sign"></i>
</a>
</label>
<div class="col-sm-8">
<select class="form-control select2_category mandatoryselect2" data-placeholder="Target Application" tabindex="1" id="applicationLinked" name="customproperty51">
<option value=""><g:message code="Select.default.label" editable="true"/></option>
<g:each var="row" in="${targetApplications}">
<option value="${row.Attribute1}" ${params.customproperty51?.equals(row.Attribute1) ? 'selected' : ''}>${row.Attribute2}</option>
</g:each>
</select>
</div>
</div>
</div>

<script>
document.getElementById('applicationLinked').addEventListener('change', function() {
let selectElement = document.getElementById('applicationLinked');
let selectedValue = selectElement.value;

// Remove trailing comma if it exists
if (selectedValue.endsWith(',')) {
selectElement.value = selectedValue.slice(0, -1);
}
});
</script>


Regards,
Rushikesh Vartak
If this helped you move forward, click 'Kudos'. If it solved your query, select 'Accept As Solution'.

Ibiza
New Contributor II
New Contributor II

@rushikeshvartak    Doesn't work. 

javadev_0-1719950746396.png

 

You need to fix in javascript


Regards,
Rushikesh Vartak
If this helped you move forward, click 'Kudos'. If it solved your query, select 'Accept As Solution'.

How?

Did you restarted application ?

<div class="col-md-6">
<div class="form-group">
<label class="control-label col-sm-4">
Target Application<span style="color:red">*</span>
<a href="javascript&colon;;" class="help tooltips" data-placement="bottom" data-toggle="tooltip" title="Target Application">
<i class="icon-info-sign"></i>
</a>
</label>
<div class="col-sm-8">
<select class="form-control select2_category mandatoryselect2" data-placeholder="Target Application" tabindex="1" id="applicationLinked" name="customproperty51">
<option value=""><g:message code="Select.default.label" editable="true"/></option>
<g:each var="row" in="${targetApplications}">
<option value="${row.Attribute1}" ${params.customproperty51?.equals(row.Attribute1) ? 'selected' : ''}>${row.Attribute2}</option>
</g:each>
</select>
</div>
</div>
</div>

 

 

<script src="https://code.jquery.com/jquery-3.6.0.min.js"></script>
<script>
$(document).ready(function() {
$('#yourFormId').on('submit', function(event) {
var selectedValue = $('#applicationLinked').val();
if (selectedValue.endsWith(',')) {
selectedValue = selectedValue.slice(0, -1); // Remove trailing comma
$('#applicationLinked').val(selectedValue);
}
});
});
</script>


Regards,
Rushikesh Vartak
If this helped you move forward, click 'Kudos'. If it solved your query, select 'Accept As Solution'.

Doesn't work either.

I don't think this is in the front end. As I'm seeing the options being populated correctly (without commas). It is like the backend is adding this comma, or interpreting the customproperty as being a list / Array. Something like that. Any hint please?

Ibiza
New Contributor II
New Contributor II

And yes I restart the app every time.

Thanks.

maybe its coming from code. Whats harm of having comma ?


Regards,
Rushikesh Vartak
If this helped you move forward, click 'Kudos'. If it solved your query, select 'Accept As Solution'.

We'll be using this value as an identifier. If it has a comma, this is a problem.

I just saw that if you choose a customproperty already used in the gsp (from the ones you'll see as grayed out later), then it's fine, there is no comma saved. But if you choose a custom property that is not already used, you'll have a comma in trailing.

So, what I'm saying if you choose one of those : 

javadev_0-1720083073418.png

 

Then it will work (no comma). But if you choose one of the others, then you'll find the comma in the saved field.

You need to fix at java script/jquery level


Regards,
Rushikesh Vartak
If this helped you move forward, click 'Kudos'. If it solved your query, select 'Accept As Solution'.