取消Dynamics CRM(iOS)中的销售线索资格

mzillmmw  于 2023-07-01  发布在  iOS
关注(0)|答案(2)|浏览(109)

如何取消Microsoft Dynamics CRM中的潜在客户资格?在iOS平台上有没有什么特殊的API可以做到这一点?我试过这个:

for (id key in [details allKeys]) {

    if([key isEqualToString:@"LeadState"])
    {
        [contactPostDict setObject:@"2" forKey:@"State"];
    }

    else if([key isEqualToString:@"LeadStatus"])
    {
        [contactPostDict setObject:@"6" forKey:@"Status"];
    }

}

这就是错误:

"error": {
"code": "", "message": {
"lang": "en-US", "value": "Error processing request stream. The property name 'Status' specified for type 'Microsoft.Crm.Sdk.Data.Services.Lead' is not valid."
}
}
mrfwxfqh

mrfwxfqh1#

我从来没有在iOS平台上工作过,但从抛出的错误来看,这个错误似乎非常直接。
您正在寻找键“状态”&“状态”,但它们不存在。相反,您应该查看它们的模式名称,如下所示
Status = statuscode,State = statecode
你可以试着修改代码来使用上面的键,看看你是否仍然得到同样的错误。

yzckvree

yzckvree2#

- (BOOL)setLeadStatus:(NSString *)ID andDetails:(NSMutableDictionary *)details
{
    NSString *uri =   [MSDYNAMICS_AUTHENTICATION_CALL stringByAppendingPathComponent:[NSString stringWithFormat:@"LeadSet(guid'%@')/",ID]];
    NSMutableURLRequest *request = [NSMutableURLRequest requestWithURL:[NSURL URLWithString:uri]];
    
    request.HTTPMethod = @"MERGE";
    
    [request setValue:JSON_CONTENT_TYPE_PARAMETER forHTTPHeaderField:@"Content-Type"];
    [request setValue:JSON_CONTENT_TYPE_PARAMETER forHTTPHeaderField:@"Accept"];
    
    
    NSMutableDictionary *contactPostDict=[[NSMutableDictionary alloc]init];
    

    for (id key in [details allKeys]) {
        
        if([key isEqualToString:@"LeadState"])
        {
            [contactPostDict setObject:@"2" forKey:@"statecode"];
        }
        
        else if([key isEqualToString:@"LeadStatus"])
        {
            [contactPostDict setObject:@"6" forKey:@"statuscode"];
        }

        
    }
    
    NSError *err;
    
    NSData *postData=[NSJSONSerialization dataWithJSONObject:contactPostDict options:NSJSONWritingPrettyPrinted error:&err];
    
    NSString* postString = [[NSString alloc] initWithData:postData encoding:NSUTF8StringEncoding];
    
    //NSString *postString = @"";
    [request setValue:JSON_CONTENT_TYPE_PARAMETER forHTTPHeaderField:CONTENT_TYPE_PARAMETER];
    [request setHTTPBody:[postString dataUsingEncoding:NSUTF8StringEncoding allowLossyConversion:YES]];
    
    
    SURLConnection  *conn = [[SURLConnection alloc] init];
    
    NSData *responseData  = [conn sendSynchronousRequest:request returningResponse:nil error:nil];
    NSString *err1 = [[NSString alloc]initWithData:responseData encoding:NSUTF8StringEncoding];
    NSLog(@"error: %@",err1);
    
    if(responseData.length==0 && [conn.response statusCode] == 204)
    {
        
        [self getLeadDetailsForID:ID];
        return YES;
    }
    
    else{
        NSString *err = [[NSString alloc]initWithData:responseData encoding:NSUTF8StringEncoding];
        NSLog(@"error: %@",err);
    }
    
    
    return NO;
}

相关问题