General Functional Discussions for Service

Get Involved. Join the Conversation.

Topic

    Mohamed Hossam
    Add multiple records to customizable menusAnswered
    Topic posted September 9, 2019 by Mohamed HossamBlue Ribbon: 750+ Points 
    13 Views, 7 Comments
    Title:
    Add multiple records to customizable menus
    Content:

    Dears,
    After Greeting ..
    Can I add multiple records to customizable menu?

     

    Version:
    19A

    Best Comment

    Sristy Arya

    Hi Mohammed,

     PFB the script to add multiple values in the menu type object.

    $flag = 360;

    $arr  =array('Test1','Test2','Test3','Test4');
    for ($i = 0; $i < count($arr); $i++) 
    {
    $country = new RNCPHP\TC\Forex_Country();   //ForexCountry here is menu type object where you want to add values 
    $country->Name =  $arr[$i];
    echo "Country name : ".$arr[$i];
    $country->DisplayOrder = $flag;
    $country->save();
    $flag++;
     
    }
     
    Note : Here the flag has been set to 360 as there is a field named DisplayOrder which is a numeric field & is required while creation of values & the last value of this field was 360 in the Database. You can change to the value according to your DB.

    Thanks

    Sristy

    Comment

     

    • Sristy Arya

      Hi Mohamed,

       

      Unable to understand what do you mean by multiple records ? Pls clarify.

      Example  : You need to add multiple Incident queues / Statuses, then yes you can do so 

       

      Thanks

      Sristy

      • Mohamed Hossam

        Hi Sristy,

        What I mean is I need to add many options/labels but not one by one because I have like 300 option/label and it`s not logic to add them manually.

         

        • Sristy Arya

          Hi Mohamed,

          You can do this via Custom Script( Connect PHP).

          Refer  :https://www.google.com/url?q=https://documentation.custhelp.com/euf/assets/devdocs/cloud19a/Connect_PHP/Default.htm&sa=D&source=hangouts&ust=1568194502937000&usg=AFQjCNGypHpep3F3MqBXo0wimDlR47vKRg 

           

          Thanks

          Sristy

          • Mohamed Hossam

            Thank you Sristy,

            Could you please provide me with the needed section in that book coz I have no experience about PHP to be able to finalize my issue urgently and Thanks in advance ...

             

            • Sristy Arya

              Hi Mohammed,

               PFB the script to add multiple values in the menu type object.

              $flag = 360;

              $arr  =array('Test1','Test2','Test3','Test4');
              for ($i = 0; $i < count($arr); $i++) 
              {
              $country = new RNCPHP\TC\Forex_Country();   //ForexCountry here is menu type object where you want to add values 
              $country->Name =  $arr[$i];
              echo "Country name : ".$arr[$i];
              $country->DisplayOrder = $flag;
              $country->save();
              $flag++;
               
              }
               
              Note : Here the flag has been set to 360 as there is a field named DisplayOrder which is a numeric field & is required while creation of values & the last value of this field was 360 in the Database. You can change to the value according to your DB.

              Thanks

              Sristy