This is a public Forum  publicRSS

Topic

    Steve Flynn
    Get meta data of custom object from customer portalAnswered
    Topic posted September 10, 2018 by Steve FlynnExplorer 
    36 Views, 2 Comments
    Title:
    Get meta data of custom object from customer portal
    Content:

    Is it possible to get the meta data of a custom object from the customer portal?

    I'm trying to find the "pattern" for a field in the object.

     

    Version:
    17D

    Best Answer

    Robert Surujbhan

    Yes. Assuming you have "RNCPHP" namespaced correctly within your Customer Portal code, you could do something like this:

    $md = RNCPHP\Package\YourCustomObj::getMetadata();
    
    $fieldMd = $md->theField;
    
    foreach ($fieldMd->constraints as $c) 
    {
        if ($c->kind == 8) {
            $thePatternOfYourField = $c->value;
        }
    }
    

    Reference material.

    Answer

     

    • Robert Surujbhan

      Yes. Assuming you have "RNCPHP" namespaced correctly within your Customer Portal code, you could do something like this:

      $md = RNCPHP\Package\YourCustomObj::getMetadata();
      
      $fieldMd = $md->theField;
      
      foreach ($fieldMd->constraints as $c) 
      {
          if ($c->kind == 8) {
              $thePatternOfYourField = $c->value;
          }
      }
      

      Reference material.

    • Pramod Vasudeva Murthy

      Yes, we can. Here is a sample controller and model I have used to test.

      All patters are defined in a fixed index as I see. So, iterate the array and get to know the index and fetch the patter.

      ~VIP

      sample_model.zip (679 Bytes)