I have a ValueService to check if there is any duplicate values in the sections .I want to find out the id of the
previewed section element. Is there any Api to find out this long id?
the current preview section id can be obtaind via
However, which duplicates do you want to identify? Each secion of a page has its unique id, so even if the values are equal (i.e. duplicates), the id's will still be different.
Anyway, to obtain the section ids via the api, this might be a good starting point:
String sUid = "my-uid";
String sPageContentContainer = "Content right";
PageStoreRoot pPageStore = (PageStoreRoot) pProject.getUserService().getStore(Store.Type.PAGESTORE, false);
Page pPage = (Page) pPageStore.getStoreElement(sUid, IDProvider.UidType.PAGESTORE);
Body pBody = pPage.getBodyByName(sPageContentContainer);
Listable vpSections = pBody.getChildren(Section.class);
for (Section _sec : vpSections)
System.out.println("Current section: " + _sec.getDisplayName(null));
System.out.println("Current section id: " + _sec.getId());
Thanks for replying to my query.
I have a page that has multiple sections .Each section form has input text for entering "key" and another input text for entering "value". I have to ensure no duplicate keys are entered in the page . So a value service is written that is triggered on entering "key" upon editing section . The value service will check if there is any duplicates in the sections.
To ensure the value service don't compare the same section, i want to pass the current edited section id as commented in the below rules ( key here is st_formfields_id) . A defect in Firstspirit is not allowing to use #global.id . So is there any other way to programmatically retrieve the current edited section id in the value service?
<SCHEDULE service="DataValueService" id="check_duplicates" delay="100">
<PROPERTY source="st_formfields_id" name="VALUE"/>
<PROPERTY source="#global.id" name="VALUE"/>
<PROPERTY source="st_formfields_id" name="VALID"/>
<MESSAGE lang="*" text="Duplicate ItemId found.ItemId should be unique."/>
is this still an open question? Do you need further help or did the given answer already help you? If so, it would be great, if you mark the reply as correct answer.
If you have found a solution by yourself, it would be very kind, if you post it here.