I'm currently recreating a form for the creation o...
# general
d
I'm currently recreating a form for the creation of a record using a suitelet. In the form, certain fields are tied together. For instance, if I were to select the account for John Doe, some other fields would get populated with information relating to John Doe. How would I implement this behavior in a suitelet. I'm thinking it would go something like this:
Copy code
// create account select input
var account = form.addField('custpage_acc', 'select', 'Account', 'customrecord_acc')

// should get populated with information relating to account selected
var additionalAccountInfo = form.addField('custpage_addinfo', 'text, 'Additional Info', <source>??)
I'm not really sure how I should source that info. Any ideas? The help would be much appreciated.
s
@ericbirdsall is correct it is on a client side. I have some examples I can send if you like.
d
Sure
s
This code is in my Suitlet to create a select list for Lead source.
var LeadSource = form.addField({
id: QIF.fields.leadSource.name,
type: ui.FieldType.SELECT,
label:  QIF.fields.leadSource.label,
container: personGroup
});
This code is in my client side on field changed
What does is clear the list in the previos code segment and reload when the companion field is changed.
Copy code
if (fldname == QIF.fields.campCat.name) {
			var desField = rec.getField({
				fieldId: QIF.fields.leadSource.name
			});
			// Remove the options.
			var ops = desField.getSelectOptions();
			var len = ops.length;
			
			for (var o=0; o < len; o++){
				if (ops[o].value > 0){
					
					desField.removeSelectOption
					({
						value: ops[o].value
					}); 
				}
			}

			var category = rec.getValue(QIF.fields.campCat.name);
			
			if (category > 0) {

				var rmfcategorySearch = search.create({
					type: search.Type.CAMPAIGN,
					columns:['title'],
					filters:[
						['category',"IS",category],
						"AND",
						['custevent_department_default',"IS","DR"]

						]});
				var campaign = rmfcategorySearch.run().getRange({
					start: 0,
					end: 1000
				});
				for (var s = 0; s < campaign.length; s++){
					
					if(campaign.length == '1'){
					desField.insertSelectOption({
						value:campaign[s].id, 
						text:campaign[s].getValue('title'),
						isSelected:true
					});
					}
					else{
						desField.insertSelectOption({
							value:campaign[s].id, 
							text:campaign[s].getValue('title')
						});
					}
						
				}
			}
		}
There may be a better way but this does work
BTW QIF.fields is an object in a library file that holds of the field ids in text
d
Alright. Thank you! I'm sure this will be a useful guide going forward.
s
no problem, if you have questions or need clarification on my code feel free to reach out.