"Can not read metaData of undefined" (Tries to push the CampaignMemberStatus label to Status field of Campaign Member)

  • 1
  • Question
  • Updated 1 month ago
Skuid Page create on Campaign Tab, and At SubTab level showing Campaign members. 

There, we have status field which we want to push the values from CampaignMemberStatus - "Label" field.

Create inline snippet for same  - 



    var element = arguments[0],value = skuid.utils.decodeHTML(arguments[1]),$ = skuid.$;
    console.log('#####'+ arguments[0]);


//Get Campaign Member model information
    var campMembermodel = skuid.model.getModel("CampaignMembers");
    
    //Fetch first row of Lead info.
    var raw= campMembermodel.getFirstRow();
    
    // Get Status field value
    var statusModel=raw.Status;
    
   alert('#####'+ statusModel);
   
 console.log('I am in CampMember Snippet');
   
   
    
    // Perform query on Campaign Member Status on basis of CampaignId
    var result = sforce.connection.query("SELECT Id,Label,CampaignId,IsDefault,HasResponded From CampaignMemberStatus where CampaignId = '7012G000001Fh8B'");
    
    
    var Att = result.getArray("records");
    
    console.log('Length'+ Att);
    
    if(Att.length!==0)
{


  // Create a array for Custom Picklist
var picklistEntries = [];


picklistEntries = element.metadata.picklistEntries;


// if you don't do this, then the "real" values are already in the picklist and the code below will add duplicate values
picklistEntries.length = 0;     


        for(var a=0;a<Att.length;a++){
           
            picklistEntries.push({ value:Att[a].Label , label:Att[a].Label, defaultValue:Att[a].IsDefault, active: true  });
        }


alert('Picklist'+ picklistEntries);



skuid.ui.fieldRenderers[element.metadata.displaytype][element.mode](element,value);


}



Error I am getting in console log - "Can not read metadata of undefined" for this line - picklistEntries = element.metadata.picklistEntries;

Can you please help us the same asap.

thanks


Photo of Rajat Maheshwari

Rajat Maheshwari

  • 140 Points 100 badge 2x thumb

Posted 1 month ago

  • 1
Photo of Luzie Baumgart

Luzie Baumgart, Official Rep

  • 2,738 Points 2k badge 2x thumb
Hi Rajat, we were also looking into this and were wondering if this should be a workaround for your other issue that you posted here: https://community.skuid.com/skuid/topics/status-field-value-not-visible-in-skuid-campaign-member-page
If yes, maybe we can solve your other issue together and this JS is longer necessary for your page.
If not, were do you use this field, as a field renderer?