Zum Hauptinhalt gehen

How to get the value from GCA(project settings) when component is language dependent?

Kommentare

2 Kommentare

  • Zendesk API User
    Author: draganr - 10/14/2021 13:41

    Hi Siva,

    the filter() method creates a new array with all elements that pass the test specified in the function, therefore you need to select the first element.

    .filter(x -> !x.masterLanguage) convert to -> .filter(x -> !x.masterLanguage)[0]

    I haven't tested your approach, but I usually extract ProjectSettings data in this way:

    $CMS_VALUE(

         #global.project.userService 

              .getStore(class("de.espirit.firstspirit.access.store.Store$Type").GLOBALSTORE, #global.release)

                   .projectProperties

                        .formData.get(#global.project.languages.filter(lang -> lang.abbreviation == "DE")[0], "ps_webchat_endpoint_url").get() 

    )$

    or, for the master language, you can use, as you already did:#global.project.masterLanguage

    Also, for the set you can use shorter version: $CMS_SET(set_editorLanguage_endpoint_url, #global.project.userService...)$

    FirstSpirit Online Documentation - CMS_SET

    Best,

    Dragan

    0
  • Zendesk API User
    Author: sivaprasad9394 - 10/20/2021 6:53

    Hi Rakita,

    Thank you for your reply and time.

    It really helped me to sole the problem.

    Assigned the CMS_VALUE to js variable before the js if condition.

    function getLocaleLanguageUrl(){

                    let localeLangUrl;                   

                    $CMS_SET(set_editorLanguage_endpoint_url,"")$

                        $CMS_SET(set_editorLanguage_endpoint_url, #global.project.userService.getStore(class("de.espirit.firstspirit.access.store.Store$Type").GLOBALSTORE, #global.release).projectProperties.formData.get(#global.project.languages.filter(lang -> lang.abbreviation.toLowerCase() == "de")[0], "ps_webchat_endpoint_url").get())$                                           

                            const langDE = '$CMS_VALUE(set_editorLanguage_endpoint_url)$';

                        $CMS_SET(set_editorLanguage_endpoint_url, #global.project.userService.getStore(class("de.espirit.firstspirit.access.store.Store$Type").GLOBALSTORE, #global.release).projectProperties.formData.get(#global.project.masterLanguage, "ps_webchat_endpoint_url").get())$

                            const langOthers = '$CMS_VALUE(set_editorLanguage_endpoint_url)$';

                            if(top.WE_API.Common.getLocale().toString() == "de"){                          

                                localeLangUrl = langDE;                       

                            }

                            if(top.WE_API.Common.getLocale().toString() != "de"){                       

                                localeLangUrl = langOthers;       

                            }               

                            return localeLangUrl;

                }

    Thanks and Regards,

    Siva

    0

Bitte melden Sie sich an, um einen Kommentar zu hinterlassen.