I need to set a field with values like "test1", "t...
# suitescript
m
I need to set a field with values like "test1", "test2", "test3" etc. Atm it's setting with with an unusual character between each element like this. SJBBSJPRTUBB How can I fix this:
Copy code
if (ss_row_count.count > 0) {
                var ss_internal_id;
                var profile_collection = [];
                ss_row_count.pageRanges.forEach(function (pageRange) {
                    const data_page = ss_row_count.fetch({
                        index: pageRange.index
                    });
                    data_page.data.forEach(function (result) {
                            ss_internal_id = result.getValue({
                                name: 'internalid',
                                summary: 'GROUP'
                            });
                            const ss_cus_profile = result.getText({
                                name: 'custrecord_profile',
                                join: 'CUSTRECORD_LOCATION',
                                summary: 'GROUP'
                            });

                            if (ss_cus_profile) {
                                profile_collection.push(ss_cus_profile);
                                return true;
                            }
                        }
                    );
                });
                setProfile(record, ss_internal_id, profile_collection);
            }
Just noticed the odd character appears to be get corrected here. But it looks like this:
b
you need to share setProfile
n
Is your value from a multi-select by any chance? I'd be inclined to output the value using charCodeAt() to ascertain what that "odd" character is, it might give you a clue but even if it doesn't you can then do a replace on it if you need to just get rid of it or split on it.
If it is a multi-select you can split it using: .split(String.fromCharCode(5)) as that's the janky separator NS uses.
m
Copy code
function setProfile(record, comments, ss_internal_id, profile_collection) {
            if (comments != profile_collection) {
                log.debug("UPDATE");
                const CUSTOMER_RECORD = record.submitFields({
                    type: record.Type.CUSTOMER,
                    id: ss_internal_id,
                    values: {
                        'comments': profile_collection
                    }
                });
                log.debug({title: "Customer Record", details: CUSTOMER_RECORD});
            }
            return true;
        }
The values I am getting is from a related record on the customer. It's a custom record. I am actually pulling the data from a saved search. I am looping through each line and putting the values together so I think it might be adding character encoding for space or linebreaks
n
Not from a multi-select then?
m
No
n
OK, well if you just need to remove them you can find out what the character is and do a replace if needed.
👍 1
m
How do I identify what the character is?
message has been deleted
n
I mentioned chatCodeAt(x) where is is the index in the string
b
dont use an array to set a text field, arrays are for multiselects
👌 1
convert the array to a string using Array.prototype.join
m
Awesome, thanks. I'm good now.