Hi,
i am new to ARIS script I have written the below code , i need to check Connection type like Any function or activity connected to org unit and internal person has connection type "is responsible for"
or" is accountable for", this is my code i am stuck can any body suggest
function Rule_867a0260_5760_11e8_44b4_0050568d644b(selection, ruleID, unused, outputObject)
{
var selModel = selection;
for(var i=0;i<selModel.length;i++){
var config = getConfiguration("2cb291d0-575f-11e8-44b4-0050568d644b");
var objocc = selModel[i].ObjOccList();
for(var j=0;j<objocc.length;j++){
var check = objocc[j].ObjDef().CxnList(Constants.EDGES_INOUT)
}
for (var k =0;k<check.length;K++){
var conn = check[k].TypeNum();
if(conn =="462" == 0){
Dialogs.MsgBox("code is working")
setSemCheckInfoMark(objocc[j],"Connection type error");
}
}}
}
Are your Activity/Function, Org unit and Internal person in the same model, the model on which you execute the report? I'm assuming yes (you really should specify a model type when you ask for such help, it would make helping you much easier). If this isn't the case, or only partly the case, feel free to tell me.
Here's an idea
<pre class="brush: jscript">
var p_selModels = ArisData.getSelectedModels();
function main(){
for each (var selModel in p_selModels){
var p_objOcc = selModel.ObjOccListBySymbol([Constants.ST_FUNC]); //Here, after a comma after Constants.ST_FUNC, add the Symbol Number of your Activity symbols
for each (var objOcc in p_objOcc){
var isAcceptable = true; //Instead of trying to prove your Function/Activity is acceptable, we assume it is acceptable and try to prove it is unacceptable for whatever specified reason
//Check if connected with Organizational unit
if(objOcc.getConnectedObjOccs(Constants.ST_ORG_UNIT_1).length == 0){
isAcceptable = false;
};
//Check if connected with Interal Person with the connection type being "is responsible for" or "is accountable for"
var p_cxnOcc = objOcc.Cxns();
for each (var cxnOcc in p_cxnOcc){
if(!(((cxnOcc.getDefinition().TypeNum() == Constants.SMTH) || (cxnOcc.getDefinition().TypeNum() == Constants.SMTH)) && (cxnOcc.SourceObjOcc().SymbolNum() == Constants.ST_PERS_INT))){ //IMPORTANT: In this line, where it says Constants.SMTH, you must somehow put the connection Type number here.
isAcceptable = false;
}
}
if(isAcceptable) {
Dialogs.MsgBox("Yes");
} else {
Dialogs.MsgBox("No");
}
}
}
}
</pre>
You can certainly NOT copy my code 1:1 into your semantic check and it works, it was never even designed for semantic checks, this is just to show you the structure that I would follow. Maybe you can take a few ideas from them and make your semantic check work.
If you have any questions, feel free to ask, I'm trying to become become a better ARISscript developer myself.
Edit: I can not get this "Synthax highlight code" thing to work, I hope you can read it anyways.
Just one advise for the future. Before you code anything, create a plan, where you write down your path of progression.
There are many different ways you can take from one object, like from an object occurrence you can take the model in which it occurs, take the group of that model, and look for object definitions in that group. Or you can go from the object occurrence to the corresponding object definition, and look for all object occurrences of that object definition.
Having a plan, and therefore a clear picture of what you want to achieve, is essential for ARIS script development (and basically for every other task that has something to do with programming). Keep that in mind, and never just "get to it".