Important Update: Community URLs redirect issues are partially resolved. Learn More. .

cancel
Showing results for 
Search instead for 
Did you mean: 

Custom Object to prevent duplicate values in a calculated field

RonaldSteiner
Collaborator II

Folks,

This question is similar to https://community.rsa.com/message/909786, but I'm going with the Custom Object approach. In my case, I have a parent/child relationship where the name of the child must be unique if within a given parent (based on parent's name). So, parent "Foo" can only have one child "Bar", but parents "Foo1" and "Foo2" can both have a child "Bar". So, I've created a text field on the child, put in on-layout, and marked it as "No Duplicates". I've created a Custom Object that gets the parent and child names and tries to write that to text field. That's where I'm having a problem.

 

I cannot seem to get the code to update the text field. It is successfully getting the values of the name fields, but will not update the text field. I know I have the right field id because I have an alert popup that shows the old value. I've tried each of the following without success:

$CM.setFieldValue(id, newValue);
ArcherTech.UI.GenericContent.GetInstance().setFieldValue(id, newValue); 
$('input[id$="'+ id +'c"]').val(newValue);

None of these seems to update the field. As usual, I have no idea which of these is the best approach, but I'd just be happy with having one of them just update the field. Or, yet another method that I haven't seen yet.

 

Thanks,

Ron

1 ACCEPTED SOLUTION

Accepted Solutions

Ilya_Khen
Champion III

You can use the following code to update Text Field, but make sure it is not set as Read Only:

function setTextField(fldId, val) {
var textFieldAttributes = new Array();
textFieldAttributes.push({
enabled: true,
emptyMessage: '',
validationText: val,
valueAsString: val,
lastSetTextBoxValue: val});

var textFieldAttributesSerialised = Sys.Serialization.JavaScriptSerializer.serialize(textFieldAttributes[0]);

$('input[id$="'+ fldId +'c"]').val(val);
$('input[id$="'+ fldId +'c_ClientState"]').val(textFieldAttributesSerialised);
}‍‍‍‍‍‍‍‍‍‍‍‍‍‍

View solution in original post

4 REPLIES 4

Ilya_Khen
Champion III

You can use the following code to update Text Field, but make sure it is not set as Read Only:

function setTextField(fldId, val) {
var textFieldAttributes = new Array();
textFieldAttributes.push({
enabled: true,
emptyMessage: '',
validationText: val,
valueAsString: val,
lastSetTextBoxValue: val});

var textFieldAttributesSerialised = Sys.Serialization.JavaScriptSerializer.serialize(textFieldAttributes[0]);

$('input[id$="'+ fldId +'c"]').val(val);
$('input[id$="'+ fldId +'c_ClientState"]').val(textFieldAttributesSerialised);
}‍‍‍‍‍‍‍‍‍‍‍‍‍‍

That did it. I guess the next step would be to do a data import to populate the new text field with the combined values so that this works going forward.

 

As usual, my final question is How do you guys figure these things out? How much of this is Archer, how much is JavaScript, how much is JQuery, and how much is mysticism?

 

Thanks,

Ron

Ron, they are sort of intertwined.  Being Archer is a web application everything is "outputted" to the browser and lives per-say in the browser document object model (DOM).  The custom object is basically injecting HTML/JavaScript into the record to perform actions.  Inspecting objects in the browser allows you to sort of see what's going on behind the curtain

 

jQuery is just a JavaScript framework that Archer utilizes. I sort of see jQuery as 'shorthand' for JavaScript.  You could just write a custom object in all native JavaScript and it wouldn't act any differently then using jQuery.

 Advisory Consultant

Simple in fact.

It is neither of the approaches you guessed, it is a phenomenon called David Petty