Click HERE to see how Saviynt Intelligence is transforming the industry. |
07/02/2024 12:52 PM
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:;" 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.
07/02/2024 12:54 PM
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:;" 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>
07/02/2024 01:05 PM
07/02/2024 02:53 PM
You need to fix in javascript
07/02/2024 02:56 PM
How?
07/02/2024 03:02 PM
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:;" 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>
07/03/2024 12:14 AM
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?
07/03/2024 12:15 AM
And yes I restart the app every time.
Thanks.
07/03/2024 09:43 PM
maybe its coming from code. Whats harm of having comma ?
07/04/2024 01:51 AM
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 :
Then it will work (no comma). But if you choose one of the others, then you'll find the comma in the saved field.
07/04/2024 09:33 AM
You need to fix at java script/jquery level