Important Update: Community URLs redirect issues are partially resolved. Learn More. .
2021-08-24 12:14 PM
I'm hoping someone can help me with the below custom object code or tell me why this isn't working in 6.9. What I'm trying to do is have the code populate a record perm field with the user who selected "Approved" on the Advanced Workflow action. Currently the code is not working in 6.9 but this code was taken from another questionnaire that is working before we upgraded and still works now in 6.9 so I'm not sure if the code isn't working because it needs to be updated due to it being a new custom object code in 6.9 or some other issue.
<script type_="text/javascript">
var setUser = {
fldId: '72713',
usersName: parent.parent.ArcherApp.globals.displayName,
userId: parent.parent.ArcherApp.globals.userId,
// Use 'group' if you're adding a group
itemType: 'user'};
//Grab Transition tab info and store it
var TransitionClickApproved = $('a[title="Approved"]').prop("onclick");
//Resets tab to trigger validation
Sys.Application.add_load(function() {
//Resets transition tab to validate rules
$('a[title="Approved"]').removeAttr('onclick').unbind('click');
$('a[title="Approved"]').prop("onclick", null);
$('a[title="Approved"]').click(function() {ApprovedMethod();});
function ApprovedMethod() {
var RPFieldRoot = ArcherTech.UI.ClientContentManager.GetInstance().getFieldById(setUser.fldId), UsrArray = [];
var RPFieldRootId = RPFieldRoot.clientId;
UsrArray.push({
name: setUser.userName,
value: setUser.userId + ':' + (setUser.itemType == 'group' ? 3 : 1)
});
var serialized = Sys.Serialization.JavaScriptSerializer.serialize(UsrArray);
$('div[id*="'+ RPFieldRootId +'_"] div:first-child').text(setUser.userName);
$('input[id*="'+ RPFieldRootId +'_"]').val(serialized);
if(setUser.itemType == 'user'){
$('#SelectedUsers'+setUser.fldId).val(setUser.userId);
}else if(setUser.itemType == 'group') {
$('#SelectedGroups'+setUser.fldId).val(setUser.userId);
} ;
// Sending it to Transition to save record and move to next step
TransitionClickApproved();
}
});
</script>
2021-08-27 08:19 AM
The new script below worked. Something had changed in 6.9 that our contractors found and provided the new script.
<script>
var setUser = {
fldId: '75590',
usersName: parent.parent.ArcherApp.globals.displayName,
userId: parent.parent.ArcherApp.globals.userId,
// Use 'group' if you're adding a group
itemType: 'user'
};
var buttonLabel = 'Approved';
//Grab Transition tab info and store it
var btnSelector = 'a[title="' + buttonLabel + '"],.action-dropdown a:contains("' + buttonLabel + '"),#master_ToolbarContainer_UI a .tb-btn:contains("' + buttonLabel + '")';
var submitToOwnerBtn = $(btnSelector);
Sys.Application.add_load(function () {
submitToOwnerBtn.mousedown(ApprovedMethod);
function ApprovedMethod() {
var RPFieldRoot = ArcherTech.UI.ClientContentManager.GetInstance().getFieldById(setUser.fldId), UsrArray = [];
var RPFieldRootId = RPFieldRoot.clientId;
UsrArray.push({
name: setUser.userName,
value: setUser.userId + ':' + (setUser.itemType == 'group' ? 3 : 1)
});
var serialized = Sys.Serialization.JavaScriptSerializer.serialize(UsrArray);
$('div[id*="' + RPFieldRootId + '_"] div:first-child').text(setUser.userName);
$('input[id*="' + RPFieldRootId + '_"]').val(serialized);
if (setUser.itemType == 'user') {
$('#SelectedUsers' + setUser.fldId).val(setUser.userId);
} else if (setUser.itemType == 'group') {
$('#SelectedGroups' + setUser.fldId).val(setUser.userId);
};
}
});
</script>
2021-08-24 12:27 PM
@OrchidTran, did you update the fldId to the correct field id of the record permission field?
Advisory Consultant
2021-08-24 12:31 PM
Yes, I updated the field id made sure the record perm field is a values popup and has "All Users" exactly how the other record perm field was configured in the questionnaire where the code is working.
2021-08-24 12:36 PM
Any errors being reported in the browsers console?
Also is the field on the layout and not set as Private (field Access tab)?
Advisory Consultant
2021-08-24 12:39 PM
There aren't any errors. When "Approved" is selected AWF completes the record but the perm field doesn't get populated. The perm field is set as public. The user goes to the record and if they are just approving then they don't fill out anything on the record, just have to click "Approved" on AWF action.
2021-08-24 04:15 PM
@OrchidTran, add a console.log(serialized); (after the variable is declared) to see what the value actual being used.
Advisory Consultant
2021-08-27 08:19 AM
The new script below worked. Something had changed in 6.9 that our contractors found and provided the new script.
<script>
var setUser = {
fldId: '75590',
usersName: parent.parent.ArcherApp.globals.displayName,
userId: parent.parent.ArcherApp.globals.userId,
// Use 'group' if you're adding a group
itemType: 'user'
};
var buttonLabel = 'Approved';
//Grab Transition tab info and store it
var btnSelector = 'a[title="' + buttonLabel + '"],.action-dropdown a:contains("' + buttonLabel + '"),#master_ToolbarContainer_UI a .tb-btn:contains("' + buttonLabel + '")';
var submitToOwnerBtn = $(btnSelector);
Sys.Application.add_load(function () {
submitToOwnerBtn.mousedown(ApprovedMethod);
function ApprovedMethod() {
var RPFieldRoot = ArcherTech.UI.ClientContentManager.GetInstance().getFieldById(setUser.fldId), UsrArray = [];
var RPFieldRootId = RPFieldRoot.clientId;
UsrArray.push({
name: setUser.userName,
value: setUser.userId + ':' + (setUser.itemType == 'group' ? 3 : 1)
});
var serialized = Sys.Serialization.JavaScriptSerializer.serialize(UsrArray);
$('div[id*="' + RPFieldRootId + '_"] div:first-child').text(setUser.userName);
$('input[id*="' + RPFieldRootId + '_"]').val(serialized);
if (setUser.itemType == 'user') {
$('#SelectedUsers' + setUser.fldId).val(setUser.userId);
} else if (setUser.itemType == 'group') {
$('#SelectedGroups' + setUser.fldId).val(setUser.userId);
};
}
});
</script>