Search Results for 'script'
-
Search Results
-
Topic: Return Record ID?
This may be a simple question, but how would I populate the current record’s ID into a field?
My objective is to make a printable label containing a QR or bar code with the link to the specified record, but I have no idea how to call the “rec-” value into a script or calculation.
All the posts I’ve found that seem to be relevant to this are directing me to a “Beta Team Membership” page.
Thanks in advance!
Good morning!
I know populating fields conditionally (based on other fields’ values) is a popular topic, so I’m posing this question as more of a plea for strategic guidance. As I’m sure will become painfully obvious, my experience with coding is entry-level at best.
The file I’m working with is a pretty basic asset inventory. The example I’ll use is: populating (multiple) spec fields based on the value of another (model) field.
When adding a new device to my “Computers” form, I need to include specific specifications such as “RAM”, “HD”, “Format”, “OS”, etc. (obviously there are many more).
Entering these values manually is not only cumbersome but also repetitive since I am often deploying multiple devices with the same characteristics. My goal is to be able to enter a value in the “model” field and have the spec fields automatically populate with that model’s corresponding values.
To accommodate this, I’ve created a “Computer Models” form containing records for each model and their respective specs. On my “Computers” form, I have a link-to field (“Linked model”) that allows me to select a record from “Computer Models”.
So here’s where I feel as though I need some strategic assistance. With guidance from other users here, I added script fields that will populate “spec” values based on the “Linked model” value. For example, the “Format” field contains the following code:
function getFormat() {var Format = 'fld-20f1f5ca216a4d7f8108f32be30c22d3';
var linked_model = record.getFieldValue('fld-a136f05b49a54749b15bedd371560ce1');if (linked_model.length > 0) {
var first_contact = linked_model[0];
Format = first_contact.getFieldValue('fld-20f1f5ca216a4d7f8108f32be30c22d3');
}return Format;
};
getFormat();
I was elated to see this successfully recognize/return the format for the chosen model, however, I’ve since observed some less-than-optimal behavior with this method:
1. The “Linked model” value is not visible or editable in multi-column view. For visual representation, I’ve addressed this by simply adding an additional “Model” field and populating it with the text value using the same scripting method as the other spec fields. This solves the visibility issue, but still does not allow me to add/edit records in multi-column view (which I tend to do often).
2. If a record’s “Linked model” field does not have a value entered, the scripted “spec” fields display the referenced field ID. Having fld-20f1f5ca216a4d7f8108f32be30c22d3 displayed results in a distracting/confusing visual representation. Ideally, I’d like the scripted fields to remain blank (or return a default vale like “unspecified” etc) in this scenario.
3. Selecting a record in the “Linked model” field feels cumbersome. This is not a huge inconvenience, but ideally, I’d love to be able to enter this value using my keyboard, as I would if it were a text or pick list selection. Currently, I’ve only been able to select a linked record by clicking on “Select existing linked records” and scrolling through the “Computer Models” records.
4. Exported data displays scripted fields in the same way multi-column view does. Exported records offer the same display as described in item #2 above.I’ve seen and tinkered with other methods, including IF/THEN and SWITCH statements, but haven’t been successful at all. Since I’m honestly not sure if my issues are with coding or the core logic behind my strategy, so I’m kneeling before the TapForms gurus here with a plea for guidance.
Any suggestions or new perspectives on my situation are welcomed and sincerely appreciated!
Thanks in advance!