Looking for help with Javascript structuring in SKUID

Nicholas L.Nicholas L. ✭✭✭
edited May 14, 2020 in Questions
I am pretty new to Javascript, was wondering if anyone could point me in the right direction. In the below script what I am attempting to do is pull in the model User_SFC (user table) and grab specific field values. Then, I want to use those values to map it to my aStr variable fields. There is another part to this script I can't include, but this is where I am having the problem. Can anyone point in the right direction?




var params = arguments[0],
    $ = skuid.$;
var User = skuid.model.getModel('User_SFC');
    var fields = [
        User.getField('City'),
        User.getField('CompanyName')];
var aStr = new Object () ; {
    aStr.city = '$fields.City';
    aStr.company_name = '$fields.CompanyName'; 

Comments

  • Anna WiersemaAnna Wiersema 🛠️ 
    edited May 14, 2020
    Hi Nicholas, 

    • What version of Skuid are you using?
    • Are you building in api V1/V2?
    • What are you trying to accomplish in this snippet? 

    If you're just trying to push the values from one object to another, you can do this declaratively via ui-only formula fields and you can create Ui only models and fields to hold values that you specify.


    As far as this snippet goes, this will get you the first row of your User_SFC model and push those values into your aStr object :

    var params = arguments[0],
    $ = skuid.$; var User = skuid.model.map().User_SFC.data[0];
    var aStr = {};
    aStr.city = User.City; aStr.company_name = User.CompanyName;

    getField()
    returns the field metadata, rather than the values on this page.

    For more reference in using Javascript and Skuid, check out Skuid's API Reference (https://docs.skuid.com/latest/v1/en/skuid/api/) if you haven't found it already.

Sign In or Register to comment.

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!