Перейти к основному содержанию
`Ctrl`+`K`

# Jexl для добавления документов к пуям

Используется для обработки документов, версий, позиций или связанных записей документа.

Место применения: `Сервис > Инструменты > Выполнить JEXL-скрипт`

Тип: JEXL-скрипт

    var nvCount = sql(`
    	select count(distinct t.id) as "nCount"
    	from (
    	(select r.idWorkStructure as id, s.gidDoc, s.gidDocVer
    	from Mct_ActionRef r
    	join Mct_Structure s on s.id = r.idStructure
    	where s.gidDoc is not null
    	) except (
    		select getgidid(ml.gidobject) as id, ml.gidlink, ml.gidlinkver
    		from mct_link ml
    		where ml.gidobject in (select mw.gid from mct_workstructure mw)
    		)
    	) t
    	`).asSingle().nCount;
    var nvIter = nvCount / 100 + 1;
    for (i : (1 .. nvIter)){
    	var ropList =  sql(`
            select distinct t.id from (
                (select r.idWorkStructure as id, s.gidDoc, s.gidDocVer
                 from Mct_ActionRef r
                 join Mct_Structure s on s.id = r.idStructure
                 where s.gidDoc is not null)
                 except
                 (select getgidid(ml.gidobject) as id, ml.gidlink, ml.gidlinkver
                 from mct_link ml
                 where ml.gidobject in (select mw.gid from mct_workstructure mw))
                              ) t
    		order by t.id
    		limit 100
    		`).foreach(function (r){
    		Mct_ActionRefApi.refreshSPLinkForWS(Mct_WorkStructureApi.getGid(r.id));
    		})
    	commit();
    }